www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14375] New: static assert leads to __traits(allMembers)

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

          Issue ID: 14375
           Summary: static assert leads to __traits(allMembers) retuning
                    an extra empty entry
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: pro.mathias.lang gmail.com

This confuses MemberFunctionsTuple alot:
/usr/include/dlang/dmd/std/traits.d(3647): Error: string expected as second
argument of __traits hasMember instead of ""

Tested with GDC (2.065), LDC (2.066.1) and 2.067

````
class IKeysAPI(string greetings) {
        static assert(greetings == "Hello world", greetings);
}

void main() {
        foreach (method; __traits(allMembers, IKeysAPI!("Hello world"))) {
                static assert (method.length, "Empty string from the compiler
??");
                pragma(msg, method);
        }
}
````

Commenting the static assert makes the foreach pass.

--
Mar 29 2015