www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16499] New: Useless error message for 'in' expressions


          Issue ID: 16499
           Summary: Useless error message for 'in' expressions
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: yshuiv7 gmail.com

struct B {
    int k;
    void* opBinaryRight(string op)(int x) if (op == "in") {
        return &k;
void main() {
    B c;

    import std.stdio;
    writeln(10 in c);
    writeln(1.0 in c);

The error reported is:

"Error: rvalue of in expression must be an associative array, not B"

Which is not true, and useless.

Sep 15 2016