[Issue 8938] New: static struct initializer allows to not explicitly initialize members with disabled constructor

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Nov 2 07:46:47 PDT 2012


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

           Summary: static struct initializer allows to not explicitly
                    initialize members with disabled constructor
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: verylonglogin.reg at gmail.com


--- Comment #0 from Denis Shelomovskij <verylonglogin.reg at gmail.com> 2012-11-02 17:46:46 MSK ---
Current behavior:
---
struct S0 { @disable this(); }
struct S  { int i; S0 s0; }

static assert(!__traits(compiles, { S0 s; }));
static assert(!__traits(compiles, { S0 s = S0(); }));
static assert( __traits(compiles, { S0 s = S0.init; }));
static assert(!__traits(compiles, {
    struct S1 { S0 s0; this(int) { } }
}));

static assert(!__traits(compiles, { S s; }));
static assert( __traits(compiles, { S s = S(5, S0.init); }));
static assert(!__traits(compiles, { S s = S(); }));     // assert failure
static assert(!__traits(compiles, { S s = S(5); }));    // assert failure
static assert(!__traits(compiles, { S x = { }; }));     // assert failure
static assert(!__traits(compiles, { S x = { i:1 }; })); // assert failure
---


It looks inconsistent because this is disabled:
---
struct S1 {
    int i;
    S0 s0;

    // Error: constructor main.S1.this field s0 must be initialized in
constructor
    this(int i) { this.i = i; }
}
---

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