Thread overview | |||||
---|---|---|---|---|---|
|
September 24, 2013 [Issue 11113] New: Weird constructor syntax failure | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=11113 Summary: Weird constructor syntax failure Product: D Version: unspecified Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: daniel350@bigpond.com --- Comment #0 from daniel350@bigpond.com 2013-09-23 21:30:47 PDT --- After adding a constructor to a struct in my code, I noticed my {} initializers were no longer compiling, with a suggestion by the compiler to use ( and ) instead. Understanding this probably means to use the full constructor prototype, not just just replace { with (, I decided to just mass replace the { and ( anyway. The resulting error was actually incredibly strange, and I can't understand the behavior of DMD in this instance, and therefore assume it is a bug. Example: struct Foo { float a, b; } void main() { Foo[] xs = [(0, 1), (2, 3), (4, 5)]; } Result: test.d(6): Error: cannot implicitly convert expression ([1, 3, 5]) of type int[] to Foo[] How/why did it reduce (.., x) to x each time? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
September 24, 2013 [Issue 11113] Weird constructor syntax failure | ||||
---|---|---|---|---|
| ||||
Posted in reply to daniel350@bigpond.com | http://d.puremagic.com/issues/show_bug.cgi?id=11113 Maxim Fomin <maxim@maxim-fomin.ru> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |maxim@maxim-fomin.ru Resolution| |INVALID --- Comment #1 from Maxim Fomin <maxim@maxim-fomin.ru> 2013-09-23 21:45:22 PDT --- Please read struct spec - it tells that adding a struct constructor breaks struct literals. For the question regarding why [(0, 1), (2, 3), (4, 5)] is [1,3,5] please read expression spec page about comma operator. Bugzilla is not a service for asking questions about what you do not understand - please user D.learn instead. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
September 24, 2013 [Issue 11113] Weird constructor syntax failure | ||||
---|---|---|---|---|
| ||||
Posted in reply to daniel350@bigpond.com | http://d.puremagic.com/issues/show_bug.cgi?id=11113 --- Comment #2 from daniel350@bigpond.com 2013-09-23 21:51:01 PDT --- Then I guess put this down as just another +1 for DIP19. -- 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