[Issue 6048] New: struct methods included in .tupleof

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon May 23 14:21:28 PDT 2011


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

           Summary: struct methods included in .tupleof
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Mac OS X
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: robert at octarineparrot.com


--- Comment #0 from Robert Clipsham <robert at octarineparrot.com> 2011-05-23 22:17:13 BST ---
The following code:
----
template canPersist(T) 
{
    enum canPersist = canPersist!(T, typeof(T.tupleof));
}

template canPersist(T, U...) 
{
    enum canPersist = canPersist!(T, U[0]) && canPersist!(T, U[1..$]);
}

template canPersist(T, U : U*)
{
    static assert(0, "is this a bug in dmd? methods shouldn't be in .tupleof");
}

void main()
{
    struct Test
    {
        bool opEquals(ref const Test other) const
        {
            return true;
        }
    }
    enum foo = canPersist!Test;
}
----
Fails to compile with:
----
prog.d(13): Error: static assert  "is this a bug in dmd? methods shouldn't be
in .tupleof"
prog.d(3):        instantiated from here: canPersist!(Test,void*)
prog.d(25):        instantiated from here: canPersist!(Test)
----

Adding additional methods to Test has no effect (they don't show up in
.tupleof), same goes for normal fields (providing you add template
canPersist(T, U) { enum canPersist = true; }). Iterating over
typeof(Test.tupleof) in main() does not give the void* type.

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


More information about the Digitalmars-d-bugs mailing list