Summary: static assert fails on true expression
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: major
          Priority: P2
         Component: DMD

--- Comment #0 from Andrej Mitrovic <> 2011-09-26 
09:14:17 PDT ---
template isDouble(T) {
    enum bool isDouble = __traits(hasMember, T, "x") || is(T == double);

void test(T)(T rhs) if (is(T == int)) { }
void test(T)(T rhs) if (isDouble!T) { }

void main()
    static assert(__traits(compiles, test(4.5)));  // fail
    test(4.5);  // fine

If you comment out the static assert you'll see that the test() call compiles.
Oddly enough if you swap the order of the calls like so:

void main()
    static assert(__traits(compiles, test(4.5)));

Then it works again.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to