Bug 10014 – `__traits(parent, ...)` isn't parsed as type
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-04-30T07:13:00Z
Last change time
2013-05-02T03:31:05Z
Keywords
rejects-valid
Assigned to
nobody
Creator
verylonglogin.reg
Comments
Comment #0 by verylonglogin.reg — 2013-04-30T07:13:49Z
---
class C { int i; }
static assert(is(__traits(parent, C.i) == C)); // Error (line 3)
template Id(T){ alias Id = T; }
static assert(is(Id!(__traits(parent, C.i)) == C)); // OK
---
dmd output:
---
main.d(3): Error: basic type expected, not __traits
main.d(3): Error: found '__traits' when expecting ')'
main.d(3): Error: found ')' when expecting ';'
---
Workaround:
Use `Id` template.
Comment #1 by verylonglogin.reg — 2013-04-30T07:15:50Z
Another workaround is to use `init` property: `typeof(__traits(parent, C.i).init)`
Comment #2 by andrej.mitrovich — 2013-05-02T03:31:05Z
*** This issue has been marked as a duplicate of issue 7804 ***