[Issue 21749] New: Misleading error message for an operator in an 'alias this'ed type

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Mar 23 09:56:21 UTC 2021


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 at puremagic.com
          Reporter: maxsamukha at 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

--


More information about the Digitalmars-d-bugs mailing list