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

          Issue ID: 17703
           Summary: __traits(compiles, AssignmentExpression) no longer
                    compiles without surrounding parens
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: [email protected]
          Reporter: [email protected]

void Test(T...)()
{
    static assert(__traits(compiles, T[0] = T[1]), "Doesn't compile");
}

void main()
{
    int x;
    int y;
    Test!(x, y)();    
}

This code fails to compile with:
(3): Error: found '=' when expecting ')' following template argument list
(3): Error: found 'T' when expecting ')' 
(3): Error: found '[' when expecting ';' 
(3): Error: found ']' when expecting ';' following statement 
(3): Error: found ')' instead of statement

It used to compile a few years ago. 

Enclosing `T[0] = T[1]` in parentheses will allow it to compile.

void Test(T...)()
{
    static assert(__traits(compiles, (T[0] = T[1])), "Doesn't compile");
}

void main()
{
    int x;
    int y;
    Test!(x, y)();    
}

--

Reply via email to