http://d.puremagic.com/issues/show_bug.cgi?id=6906
Kenji Hara <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|wrong-code |rejects-valid Status|NEW |RESOLVED Platform|Other |All Resolution| |FIXED OS/Version|Windows |All --- Comment #4 from Kenji Hara <[email protected]> 2013-09-07 10:01:04 PDT --- (In reply to comment #0) > This code fails to compile because the struct S implement opAssign and the > compiler tries using it rather than the associative arrays insert. > > void main() { > S[string] ss; > S s; > > ss["hello"] = s; > } > > struct S { > void opAssign(int i) { > } > } > > test.d(6): Error: function test.S.opAssign (int i) is not callable using > argument types (S) > test.d(6): Error: cannot implicitly convert expression (s) of type S to int > test.d(6): Error: function test.S.opAssign (int i) is not callable using > argument types (S) > test.d(6): Error: cannot implicitly convert expression (s) of type S to int > PS C:\Documents and Settings\jphillips\src\Juno> dmd test.d > test.d(5): Error: function test.S.opAssign (int i) is not callable using > argument types (S) > test.d(5): Error: cannot implicitly convert expression (s) of type S to int > test.d(5): Error: function test.S.opAssign (int i) is not callable using > argument types (S) > test.d(5): Error: cannot implicitly convert expression (s) of type S to int >From 2.062, the code could work. Even if a struct has only non-identity opAssign methods, identity assignment would be rewritten to the field-to-field assignment. struct S { int val; void opAssign(int i) {} } void main() { S s; S s2; s = s2; // Rewite as: s.tupleof = s2.tupleof; s = 1; // Rewrite as: s.opAssign(1) } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
