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: nob...@puremagic.com
        ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@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: -------

Reply via email to