www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10014] New: `__traits(parent, ...)` isn't parsed as type

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10014

           Summary: `__traits(parent, ...)` isn't parsed as type
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: verylonglogin.reg gmail.com


--- Comment #0 from Denis Shelomovskij <verylonglogin.reg gmail.com> 2013-04-30
18:13:49 MSD ---
---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 30 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10014



--- Comment #1 from Denis Shelomovskij <verylonglogin.reg gmail.com> 2013-04-30
18:15:50 MSD ---
Another workaround is to use `init` property: `typeof(__traits(parent,
C.i).init)`

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 30 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10014


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrej.mitrovich gmail.com
         Resolution|                            |DUPLICATE


--- Comment #2 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-05-02
03:31:05 PDT ---
*** This issue has been marked as a duplicate of issue 7804 ***

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