http://d.puremagic.com/issues/show_bug.cgi?id=5877

           Summary: Cannot 'alias __traits(parent, obj) X;'
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: kenn...@gmail.com


--- Comment #0 from kenn...@gmail.com 2011-04-23 23:13:49 PDT ---
Since the introduction of __traits(parent) in commit 2e261cd6, it is possible
that the __traits expression returns a type. However, the parser does not
recognize this in an alias statement, and rejects the code.

--------------------------------------------------------
class B {
    int x();
    alias __traits(parent, x) S;
    static assert(is(B == S));
}
--------------------------------------------------------
x.d(3): basic type expected, not __traits
x.d(3): no identifier for declarator int
x.d(3): semicolon expected to close alias declaration
x.d(3): Declaration expected, not '__traits'
--------------------------------------------------------

A workaround is to create an existing expression that returns a type:

--------------------------------------------------------
class B {
    int x();
    alias typeof(__traits(parent, x).init) S;
    static assert(is(B == S));
}
--------------------------------------------------------

But it is better the __traits work without these hacks.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to