digitalmars.D.bugs - [Issue 19708] New: Can't use __traits(getAttributes, ...)[...] as a
- d-bugmail puremagic.com (40/40) Feb 28 2019 https://issues.dlang.org/show_bug.cgi?id=19708
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 puremagic.com Reporter: moonlightsentinel 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 --
Feb 28 2019