[Issue 9372] Class member with @disabled ctor makes class ctor unusable

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jan 23 11:57:40 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9372



--- Comment #6 from Jacob Carlborg <doob at me.com> 2013-01-23 11:57:38 PST ---
(In reply to comment #5)
> It should be illegal to reference an uninitialized variable in the ctor.
> Something similar to how immutable fields are handled can be applied here:
> you're not allowed to read the value of an immutable field until it's
> initialized, and it can only be written to once.

The following code with compiles DMD 2.061 and when it runs it prints "0".

import std.stdio;

class Foo
{
    immutable int a;

    this ()
    {
        writeln(a);
        a = 3;
    }
}

void main ()
{
    new Foo;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list