[Issue 19708] New: Can't use __traits(getAttributes, ...)[...] as a type
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Feb 28 14:56:20 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=19708
Issue ID: 19708
Summary: Can't use __traits(getAttributes, ...)[...] as a type
Product: D
Version: D2
Hardware: x86_64
OS: Windows
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: moonlightsentinel at disroot.org
The result of __traits(getAttributes, ...)[..] can't be used as a type. Instead
dmd produces some misleading error messages depending on the context.
Consider the following example:
---------------
module test;
struct Foo {}
@Foo int bar;
alias TR = __traits(getAttributes, bar);
/* Error: TR[0] is not a type
TR[0] a;
*/
/* Error: type Foo is not an expression
typeof(TR[0]) b;
*/
/* alias `test.c` cannot alias an expression Foo
alias c = TR[0];
*/
/* __traits(getAttributes, bar) does not give a valid type
alias d = __traits(getAttributes, bar)[0];
*/
// Possible workaround using a tuple
alias Tuple(T...) = T;
alias TP = Tuple!(__traits(getAttributes, bar));
TP[0] e;
---------------
Probably related to issue 16390
--
More information about the Digitalmars-d-bugs
mailing list