[Issue 3744] __traits getMember error in checking of second argument
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jun 29 21:43:25 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3744
yebblies <yebblies at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |yebblies at gmail.com
Platform|x86 |All
Resolution| |FIXED
OS/Version|Linux |All
--- Comment #12 from yebblies <yebblies at 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: -------
More information about the Digitalmars-d-bugs
mailing list