www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14236] New: opIndexUnary and opIndex fallback


          Issue ID: 14236
           Summary: opIndexUnary and opIndex fallback
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: john.loughran.colvin gmail.com

struct S
    auto opIndex(size_t i)
        return 1;
    auto opIndexUnary(string s)(size_t i, size_t j)
        return -1;

    S s;
    assert(-s[0] == -1);

this fails to compile because the compiler won't fall back to using opIndex
when it can't find an applicable opIndexUnary

Mar 02 2015