[Issue 11113] New: Weird constructor syntax failure

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Sep 23 21:30:48 PDT 2013


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 at puremagic.com
        ReportedBy: daniel350 at bigpond.com


--- Comment #0 from daniel350 at 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: -------


More information about the Digitalmars-d-bugs mailing list