[Issue 3863] New: Various errors and ICEs for struct constructors with ellipses

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Feb 28 02:41:02 PST 2010


http://d.puremagic.com/issues/show_bug.cgi?id=3863

           Summary: Various errors and ICEs for struct constructors with
                    ellipses
           Product: D
           Version: 2.041
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: ice-on-valid-code, rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: ludwig at informatik.uni-luebeck.de


--- Comment #0 from Sönke Ludwig <ludwig at informatik.uni-luebeck.de> 2010-02-28 02:41:00 PST ---
The following code snipped lists a number of ways to define a struct constant
which fail compilation in one way or another. This happens only 

---
struct Vec(int N){
    //static immutable constant = Vec(1, 2); // error more initializers than
fields
    //static immutable Vec constant = Vec(1, 2); // compiles
    //enum constant = Vec(1, 2); // error more initializers than fields
    enum Vec constant = Vec(1, 2); // compiles

    this(const float[N] args...) {}
    //this(float a, float b) {} // all cases compile
}

struct Test {
    alias Vec!2 Vec2;

    Vec2 member;

    //static immutable constant = Test(Vec!2(1, 2)); // compiler crash
    //static immutable Test constant = Test(Vec!2(1, 2)); // assertion failure
on todt.c:688
    //static immutable constant = Test(Vec!(2).constant); // assertion failure
on todt.c:688
    //enum constant = Test(Vec!(2).constant); // compiles
    enum Test constant = Test(Vec2.constant); // compiles
    //enum Test constant = Test(Vec2(1, 2)); // error void initializer has no
value

    this(Vec2 x){
        member = x;
    }
}
---



When the first sturct is not templated, the situation changes:

---
struct Vec {
    static immutable Vec constant = Vec(1, 2);

    this(const float[2] args...) {}
}

struct Test {
    alias Vec Vec2;

    Vec2 member;

    static immutable constant = Test(Vec2(1, 2)); // compiler crash
    //static immutable Test constant = Test(Vec2(1, 2)); // compiles
    //static immutable constant = Test(Vec2.constant); // compiles
    //enum constant = Test(Vec2.constant); // compiles
    //enum Test constant = Test(Vec2.constant); // compiles
    //enum Test constant = Test(Vec2(1, 2)); // error void initializer has no
value

    this(Vec2 x){
        member = x;
    }
}
---



Using an enum in the first struct makes things worse:

---
struct Vec {
    enum Vec constant = Vec(1, 2);

    this(const float[2] args...) {}
}

struct Test {
    alias Vec Vec2;

    Vec2 member;

    static immutable constant = Test(Vec2(1, 2)); // compiler crash
    //static immutable Test constant = Test(Vec2(1, 2)); // compiles
    //static immutable constant = Test(Vec2.constant); // compiler crash
    //enum constant = Test(Vec2.constant); // compiler crash
    //enum Test constant = Test(Vec2.constant); // error void initializer has
no value
    //enum Test constant = Test(Vec2(1, 2)); // error void initializer has no
value

    this(Vec2 x){
        member = x;
    }
}
---

-- 
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