September 09, 2013 [Issue 11000] New: Static field type inference failure | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=11000 Summary: Static field type inference failure Product: D Version: D2 Platform: All OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: daniel350@bigpond.com --- Comment #0 from daniel350@bigpond.com 2013-09-09 16:56:30 PDT --- ```struct Foo { int a; this(int a) { this.a = a; } // reason for fail static immutable bar = Foo(1); // fails // static immutable Foo bar = Foo(1); // works } void main() { auto a = Foo.bar; } ``` The code above should compile, instead: `test.d(6): Error: cannot create a struct until its size is determined`. Remove the explicit constructor at line 4, and line 6 compiles. Add the explicit type onto the type declaration (as on line 7), and it will work without removing the explicit constructor. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
September 10, 2013 [Issue 11000] Static field type inference failure | ||||
---|---|---|---|---|
| ||||
Posted in reply to daniel350@bigpond.com | http://d.puremagic.com/issues/show_bug.cgi?id=11000 Andrej Mitrovic <andrej.mitrovich@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrej.mitrovich@gmail.com --- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-09-09 18:03:19 PDT --- This looks like a dupe I've seen before. Reduced: ----- struct Foo { this(int) {} static f = Foo(1); } void main() { } ----- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation