Thread overview | |||||
---|---|---|---|---|---|
|
September 10, 2012 [Issue 8638] New: built-in array opSliceAssign fails with user defined opAssign | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=8638 Summary: built-in array opSliceAssign fails with user defined opAssign Product: D Version: unspecified Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: monarchdodra@gmail.com --- Comment #0 from monarchdodra@gmail.com 2012-09-10 06:35:34 PDT --- In a word: -------- struct S { void opAssign(int j); } void main() { int[] i; i[] = 5; //Here1 S[] s; s[] = 5; //Here2 } -------- Actual behavior: Here2: Error: cannot implicitly convert expression (5) of type int to S[] Expected behavior: Here2: opAssign(5) is called for each member of s, just like for Here1. Ditto for all other flavors of opSliceSomething. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
September 12, 2012 [Issue 8638] built-in array opSliceAssign fails with user defined opAssign | ||||
---|---|---|---|---|
| ||||
Posted in reply to monarchdodra@gmail.com | http://d.puremagic.com/issues/show_bug.cgi?id=8638 --- Comment #1 from monarchdodra@gmail.com 2012-09-12 01:47:03 PDT --- The issue can be worked around as such: -------- struct S { int i; void opAssign(S); void opAssign(int j); } void main() { ulong[] i; i[] = cast(ushort)5; //Here1 S[] s; s[] = S(5); //Here2 } -------- However, this shifts the requirement: *from isAssignable!(S,V) *to isAssignable!(S,S) && "canBeConstructedFrom!(S, V)" Where S is the user defined struct, and V is another type. Note that the built-in opSliceAssign DOES support assignement of V to S (HERE1), so there is indeed a limitation/bug/ER. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
September 16, 2012 [Issue 8638] built-in array opSliceAssign fails with user defined opAssign | ||||
---|---|---|---|---|
| ||||
Posted in reply to monarchdodra@gmail.com | http://d.puremagic.com/issues/show_bug.cgi?id=8638 monarchdodra@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |enhancement --- Comment #2 from monarchdodra@gmail.com 2012-09-16 14:14:17 PDT --- Just wanted to document that the issue also exists for opOpAssign: -------- struct S { void opOpAssign(int); } void main() { S[] ss; ss[]+=1; } -------- Also, I'm not 100% sure if this is a bug or not, but I believe it *should* work, so I'm re-labeling as ER -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation