[Issue 20762] New: __traits(isSame) is underspecified for enums and literals

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Apr 23 08:43:06 UTC 2020


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

--


More information about the Digitalmars-d-bugs mailing list