[Issue 3905] New: Wrong error message with wrong opBinary("in")
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Mar 8 16:10:12 PST 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3905
Summary: Wrong error message with wrong opBinary("in")
Product: D
Version: 2.041
Platform: x86
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at eml.cc 2010-03-08 16:10:09 PST ---
This D2 program is wrong, because it needs a opBinaryRight to work:
struct Group {
int i1, i2;
bool opBinary(string s:"in")(int x) {
return x == this.i1 || x == this.i2;
}
}
auto enum r = 3 in Group(1, 2);
void main() {}
But the compiler gives a bad error message, that doesn't help the programmer
much (and there are no associative arrays in this program):
test.d(7): Error: rvalue of in expression must be an associative array, not
Group
For example a better error message can be:
test.d(7): Error: Group has no opBinaryRight("in") operator and int has no
opBinary("in") operator.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list