[Issue 19115] Object and Collection Initializers

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jul 24 09:58:54 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=19115

--- Comment #2 from OlegZ <black80 at bk.ru> ---
struct p2 { int x, y; }
struct p3 { p2 p; alias p this; int z; }

p3 p = { x:1, y:2, z:3 }; // case (1)
// we've got error: `x` is not a member of `p3`. works only for "z" alone

// try again
p3 p = { p = { x:1, y:2 }, z:3 }; // many another errors

// try again
p3 p = { p.x:1, z:3 }; // many another errors

// try again
p3 p = { z:3 };
p.p.x = 1; // internal struct .p.
p.y = 2; // simpler .
// WOW! NO ERRORS! but looks stupid

I can see error if I try to initialize one field twice, I don't see another
errors in case (1)

assign list or initialization with list should be simpler (that means faster
parser)

--


More information about the Digitalmars-d-bugs mailing list