digitalmars.D.bugs - [Issue 3905] New: Wrong error message with wrong opBinary("in")
- d-bugmail puremagic.com (32/32) Mar 08 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3905
- d-bugmail puremagic.com (20/20) Sep 30 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3905
- d-bugmail puremagic.com (6/6) Sep 30 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3905
- d-bugmail puremagic.com (26/26) Dec 04 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3905
- d-bugmail puremagic.com (27/27) Dec 04 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3905
- d-bugmail puremagic.com (10/10) Dec 11 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3905
- d-bugmail puremagic.com (6/6) Jan 16 2013 http://d.puremagic.com/issues/show_bug.cgi?id=3905
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 puremagic.com ReportedBy: bearophile_hugs eml.cc 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: -------
Mar 08 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3905 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |diagnostic, patch CC| |clugdbug yahoo.com.au PATCH: expression.c, line 10624, InExp::semantic() default: - error("rvalue of in expression must be an associative array, not %s", e2->type->toChars()); + error("%s has no opBinaryRight(\"in\") operator and %s has no opBinary(\"in\") operator", e1->type->toChars(), e2->type->toChars()); case Terror: return new ErrorExp(); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 30 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3905 Thank you Don :-) I need to be able to write a patch like this by myself. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 30 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3905 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla digitalmars.com Resolution| |WONTFIX 18:36:08 PST --- I'm not convinced this new error message is an improvement. All the expression error messages work on the assumption that operator overloads do not exist, as that is the normal case. Trying to write an error message for the normal case in terms of "you screwed up the operator overloads" is not helpful. For example, int a; double b; a in b; will give a pretty much incomprehensible error message to the user: test.d(7): Error: double has no opBinaryRight("in") operator and int has no opBinary("in") operator. ??? I'd prefer to leave the message as is. If someone is doing operator overloading, the message makes it clear the operator overloading failed to find a match. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 04 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3905 Steven Schveighoffer <schveiguy yahoo.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED CC| |schveiguy yahoo.com Resolution|WONTFIX | 22:46:00 PST --- I agree that the proposed patch is not better. But the original message is invalid. This is a bug that needs to be fixed, regardless of whether you like the given proposals. Point in fact, in *can* work on types besides associative arrays. I tried this: struct S {} void main() { S s; auto t = s + s; } And got: Error: incompatible types for ((s) + (s)): 'S' and 'S' So extrapolating to in, the error should look like: Error: incompatible types for ((3) in (Group(1, 2))): 'int' and 'Group' Although, I'm unsure why there are so many parentheses... -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 04 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3905 Saying that double has no "in" is correct (even if it's a bit noisy and overkill), while saying "rvalue of in expression must be an associative array, not Group" is wrong. I think this bug report is valid still, because the current error message is confusing. So a better solution will be useful. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 11 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3905 *** Issue 7837 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 16 2013