www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20762] New: __traits(isSame) is underspecified for enums and

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

          Issue ID: 20762
           Summary: __traits(isSame) is underspecified for enums and
                    literals
           Product: D
           Version: D2
          Hardware: x86
                OS: All
            Status: NEW
          Keywords: spec
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: maxsamukha gmail.com

https://dlang.org/spec/traits.html

"2. If the two arguments are expressions made up of literals or enums that
evaluate to the same value, true is returned."

enum x = 1;
// this fails because x is treated as symbol
static assert(__traits(isSame, x, 1));

// this passes because now x is an expression
static assert(__traits(isSame, (x), 1));

The spec should be clear about this.

--
Apr 23 2020