www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21896] New: static if test fails after alias assignment

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

          Issue ID: 21896
           Summary: static if test fails after alias assignment
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: andrei erdani.com

Consider the code below. The first static assert passes, the second fails:

template Works(T)
{
    static if (is(T U == const U)) 
    {
        pragma(msg, "is const");
        alias Works = U;
    }
    else
    {
                alias Works = T;
    }
}

template Fails(T)
{
    alias Fails = T;
    static if (is(T U == const U)) 
    {
        pragma(msg, "assigning");
        Fails = U;
    }
}

static assert(is(Works!(const int) == int));
static assert(is(Fails!(const int) == int));

--
May 06