Thread overview |
---|
December 06, 2006 [Issue 655] New: Operator overload uses opIndex instead of opIndexAssign | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=655 Summary: Operator overload uses opIndex instead of opIndexAssign Product: D Version: 0.176 Platform: PC OS/Version: Windows Status: NEW Keywords: accepts-invalid Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: brunodomedeiros+bugz@gmail.com In an array assignment expression, operator overload uses opIndex instead of opIndexAssign. ---------- import std.stdio; struct Moo { void opIndex(int i, int i2) { writefln("opIndex:", i, i2); } } int main(char[][] args) { Moo m = *new Moo(); m[0, 42]; // uses opIndex , ok m[0] = 42; // uses opIndex instead of opAssign, not ok according to spec return 0; } -- |
December 06, 2006 [Issue 655] Operator overload uses opIndex instead of opIndexAssign | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=655 ------- Comment #1 from brunodomedeiros+bugz@gmail.com 2006-12-06 08:43 ------- Agh, read the comment above as: m[0] = 42; // uses opIndex instead of opIndexAssign, not ok according to spec -- |
December 06, 2006 [Issue 655] Operator overload uses opIndex instead of opIndexAssign | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=655 ------- Comment #2 from jarrett.billingsley@gmail.com 2006-12-06 09:18 ------- > import std.stdio; > > struct Moo { > void opIndex(int i, int i2) { > writefln("opIndex:", i, i2); > } > } > > int main(char[][] args) { > Moo m = *new Moo(); > m[0, 42]; // uses opIndex , ok > m[0] = 42; // uses opIndex instead of opAssign, not ok according to spec > > return 0; > } > When I compile that snippet in 0.176, I get the error: dtest.d(134): Error: operator [] assignment overload with opIndex(i, value) deprecated, use opIndexAssign(value, i) Is that what you mean? Or does it compile for you? I think it's a vestige of some _very_ old operator overloading behavior, Walter probably missed it. -- |
December 07, 2006 [Issue 655] Operator overload uses opIndex instead of opIndexAssign | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=655 brunodomedeiros+bugz@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID ------- Comment #3 from brunodomedeiros+bugz@gmail.com 2006-12-07 13:23 ------- My mistake, I was compiling with -d (allow deprecated) and didn't notice it. -- |
Copyright © 1999-2021 by the D Language Foundation