[Issue 20831] New: __traits(getAttributes) failes to compile when used on a parameter with no name
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu May 14 14:23:28 UTC 2020
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 at puremagic.com
Reporter: atila.neves at 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.
--
More information about the Digitalmars-d-bugs
mailing list