[Issue 10643] Refused const array struct field initialized with void

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Dec 14 11:12:50 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=10643



--- Comment #6 from Kenji Hara <k.hara.pg at gmail.com> 2013-12-14 11:12:44 PST ---
(In reply to comment #0)
> class Bar {
>     const int[1000] x = void;
>     this(int n) {
>         x[] = n;
>     }
> }
> void main() {}

http://dlang.org/changelog.html#staticfields
In 2.063, just only warning was added for implicitly static aggregate members.
So currently, Bar.x is still made static implicitly.

And, you cannot initialize static variable inside instance constructor.
Therefore, essentially current behavior is not a bug.

...But, fortunately(?), void initialized variable is currently not
initializable inside static constructor. 

class Bar {
    const int x = void;
    static this() { x = 1; }  // NG!
}
const int x = void;
static this() { x = 10; }  // NG!

This is another compiler bug (I filed it in bug 11742). But for the reason we
can fix this issue without breaking any existing code.

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


More information about the Digitalmars-d-bugs mailing list