www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19409] New: static if (__traits(compiles,

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

          Issue ID: 19409
           Summary: static if (__traits(compiles, __traits(identifier,
                    ...))) evaluates to false even though the expression
                    alone evaluates to true
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: zorael gmail.com

Manjaro/Arch x86_64, dmd v2.083, ldc 1.12.0, gdc 8.2.1/2.081.2.

https://run.dlang.io/is/4wfH1q

Running it on run.dlang.io with all dmd compilers seems to suggest it's a
2.071.x regression.

---

module test.foo;

pragma(msg, __traits(identifier, test.foo)); // "foo"

pragma(msg, __traits(compiles, __traits(identifier, test.foo))); // true

static assert(__traits(compiles, __traits(identifier, test.foo))); // passes

static if (__traits(compiles,  __traits(identifier, test.foo))) // fails
{
    pragma(msg, "Never gets here");
}
else
{
    static assert(0);
}

void main() {}

--
Nov 18 2018