[Issue 12287] infinite loop on std.traits.moduleName on templated struct member

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Mar 2 19:00:25 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=12287



--- Comment #10 from Kenji Hara <k.hara.pg at gmail.com> 2014-03-02 19:00:17 PST ---
(In reply to comment #9)
> (In reply to comment #8)
> > Because your compiler change will make some part of the internal structure of
> > the template instantiation invisible. 
> 
> I don't understand. Why?
> 
> Before my patch: __traits(parent, X!foo) is the same symbol as X!foo. It did
> not reveal any internal structure at all, the result was completely useless.

Internally X!foo is exactly same as X!foo.X. So __traits(parent, X!foo) will
return the parent of the instantiated type X - that is the TemplateInstance
'X!foo'. They are completely different objects.
But, latter semantic analysis will translate X!foo to X!foo.X again. The
behavior is not directly related to the __traits(parent) behavior.

> After my patch, it produces the result that a casual user may expect from an
> eponymous template, especially when declared like struct S(Args) {...}

I think it's not consistent behavior in generic case. For example:

template S(T)
{
    struct S {}

    int x;
    static assert(__traits(isSame, __traits(parent, S),
                                   __traits(parent, x)));
}
alias s = S!int;

Your change will break this case.

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


More information about the Digitalmars-d-bugs mailing list