digitalmars.D.bugs - [Issue 20831] New: __traits(getAttributes) failes to compile when
- d-bugmail puremagic.com (36/36) May 14 2020 https://issues.dlang.org/show_bug.cgi?id=20831
https://issues.dlang.org/show_bug.cgi?id=20831 Issue ID: 20831 Summary: __traits(getAttributes) failes to compile when used on a parameter with no name Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: atila.neves gmail.com With dmd v2.091.1, this code fails to compile (it doesn't even print fail in the pragma, it just doesn't compile): ---------------------------------------- void foo(int f, float, ("test") string s = "test") {} static if(is(typeof(foo) Params == __parameters)) pragma(msg, __traits(getAttributes, Params[1..2])); else pragma(msg, "fail"); ---------------------------------------- But moving the code to a function makes it work somehow: ---------------------------------------- void foo(int f, float, ("test") string s = "test") {} void main() { static if(is(typeof(foo) Params == __parameters)) pragma(msg, __traits(getAttributes, Params[1..2])); else pragma(msg, "fail"); } ---------------------------------------- The 2nd version correctly prints "tuple()". In the 1st non-working version, naming the 2nd parameter also makes the problem go away. --
May 14 2020