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


yebblies <yebbl...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebbl...@gmail.com
           Platform|x86                         |All
         Resolution|                            |FIXED
         OS/Version|Linux                       |All


--- Comment #12 from yebblies <yebbl...@gmail.com> 2011-06-30 14:38:26 EST ---
(In reply to comment #10)
> Interestingly it still doesn't work even though allMembers returns a tuple
> since r360:
> 
> 4: foreach(m; __traits(allMembers, Check)){
> 5:    if (!__traits(isVirtualFunction, __traits(getMember, Check, m))){
> 6:        writefln("Var: s%, Type: %s", m, typeid(typeof(m)));
>     }
> }
> 
> yields:
> 
> main.d(5): Error: 'this' is only defined in non-static member functions, not
> main
> main.d(5): Error: this for a needs to be type Check not type int

It actually works correctly now (dmd 2.053).
The errors in the sample above are because it's not possible to get a member
variable of from the class type, you need an instance.

The following works:

--

import std.stdio;

class Check { void foo() {} int bar() { return 0; } invariant() {} int x; }

void main()
{
    Check check;
    foreach(m; __traits(allMembers, Check))
    {
        if (!__traits(isVirtualFunction, __traits(getMember, check, m))){
            writefln("Var: %s, Type: %s", m, typeid(typeof(m)));
        }
    }
}

--

The bug was fixed when __traits(allMembers) started returning a tuple.

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

Reply via email to