www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21749] New: Misleading error message for an operator in an

https://issues.dlang.org/show_bug.cgi?id=21749

          Issue ID: 21749
           Summary: Misleading error message for an operator in an 'alias
                    this'ed type
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: maxsamukha gmail.com

struct S {
    void opUnary(string op: "++")() {
        bad;
    }
}

struct S2 {
    S s;
    alias s this;
}

void main() {
    S2 s;
    ++s;
}

Error: s is not a scalar, it is a S2


The error should be similar to that when the operator is called explicitly:

void main() {
    S2 s;
    s.opUnary!"++"();
}

onlineapp.d(4): Error: undefined identifier bad
onlineapp.d(15): Error: template instance onlineapp.S.opUnary!"++" error
instantiating

--
Mar 23