www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21466] New: Calling an enum value result in confusing error

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

          Issue ID: 21466
           Summary: Calling an enum value result in confusing error
                    message "No property X for type Y"
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: diagnostic
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: pro.mathias.lang gmail.com

Reduced case:
```
enum Foo
{
    a,
    b,
}

void main ()
{
    auto z = Foo.a(STC.b);
}
```
Gives:
```
parseme.d(9): Error: no property a for type int
```

This is quite confusing, as the error message doesn't actually tell what's
wrong (a is not callable).
This is reduced from a bigger error, where the actual code used a ternary and
was missing a bitwise OR (`|`), causing the line to be interpreted as a call.

--
Dec 10 2020