digitalmars.D.bugs - [Issue 11113] New: Weird constructor syntax failure
- d-bugmail puremagic.com (34/34) Sep 23 2013 http://d.puremagic.com/issues/show_bug.cgi?id=11113
- d-bugmail puremagic.com (16/16) Sep 23 2013 http://d.puremagic.com/issues/show_bug.cgi?id=11113
- d-bugmail puremagic.com (6/6) Sep 23 2013 http://d.puremagic.com/issues/show_bug.cgi?id=11113
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
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: -------
Sep 23 2013
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
---
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: -------
Sep 23 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11113 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: -------
Sep 23 2013









d-bugmail puremagic.com 