July 29, 2017 [Issue 17703] New: __traits(compiles, AssignmentExpression) no longer compiles without surrounding parens | ||||
|---|---|---|---|---|
| ||||
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@puremagic.com Reporter: slavo5150@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)(); } -- | ||||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply