www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22269] New: __traits(isSame) does not work for values passed


          Issue ID: 22269
           Summary: __traits(isSame) does not work for values passed to
                    template alias parameters
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: b2.temp gmx.com

static assert(__traits(isSame, 0, 0));  // OK
enum isSame(alias a, alias b) = __traits(isSame, a, b);
static assert(isSame!(0,0));            // NG   

1. the 2nd static assertion fails, which is surprising.
it does not if isSame signature is changed, e.g changing the template
parameters to value parameters or a variadic parameter.

2. it was made observation on the forum[1] that this leads to std.traits.isSame
to be more complex than it should.

[1]: https://forum.dlang.org/post/lsckaoejcmfnifcbsqjf forum.dlang.org

Sep 03 2021