[Issue 17703] New: __traits(compiles, AssignmentExpression) no longer compiles without surrounding parens

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Jul 29 11:52:20 PDT 2017


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: nobody at puremagic.com
          Reporter: slavo5150 at yahoo.com

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)();    
}

--


More information about the Digitalmars-d-bugs mailing list