http://d.puremagic.com/issues/show_bug.cgi?id=11206
Kenji Hara <k.hara...@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|rejects-valid | --- Comment #14 from Kenji Hara <k.hara...@gmail.com> 2013-10-10 02:00:57 PDT --- (In reply to comment #12) > > I think we could apply the same rule to the relation of struct literal > > syntax > > arguments and corresponding struct field type. > > > > Agg!S agg = Agg!S(1); // #1 > > S[1] ssa = [1]; // #2 > > > > It looks like when you are speaking about struct literal syntax you mean both > struct literal and struct constructors (probably even opCall). It seems that > Agg!S(1) would be valid either if there is constructor taking int or first > member is integer type. Do you consider documenting it after merging > corresponding pull? No. I strictly distinguish struct literal and struct constructor call. struct S1 { int num; } // S1(1) is literal syntax struct S2 { this(int); } // S2(1) is ctor call struct S3 { static S3 opCall(int); } // S3(1) is static function call struct A1(T) { T val; } struct A2(T) { this(T); } void main() { S1 s1 = 1; // should be NG, int is not implicitly convertible to S1 S2 s2 = 1; // OK. The S2 ctor accepts int value as a valid initializer, // then it's implicitly invoked for initialization. S3 s3 = 1; // NG. opCall is completely unrelated to initializing. // Note that A1!T(...) is always literal syntax A1!S1 a11 = A1!S1(1); // NG, int is not implicitly convertible to S1 A1!S2 a12 = A1!S2(1); // should be OK, as same as the 's2' case. A1!S3 a13 = A1!S3(1); // Of course NG. // Note that A2!T(...) is constructor call A2!S1 a21 = A2!S1(1); // NG, int is not implicitly convertible to S1 A2!S2 a22 = A2!S2(1); // NG, int is not implicitly convertible to S1 A2!S3 a23 = A2!S3(1); // NG, int is not implicitly convertible to S1 } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------