[Issue 14844] [REG2.068a] __traits(allMembers) must not visit yet not instantiated template members

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Jul 28 20:47:08 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=14844

Kenji Hara <k.hara.pg at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Hardware|x86_64                      |All
            Summary|dmd-2.068.0-b2              |[REG2.068a]
                   |attrib.c:1233: virtual      |__traits(allMembers) must
                   |Dsymbols*                   |not visit yet not
                   |StaticIfDeclaration::includ |instantiated template
                   |e(Scope*, ScopeDsymbol*):   |members
                   |Assertion `scopesym' failed |
                 OS|Linux                       |All

--- Comment #2 from Kenji Hara <k.hara.pg at gmail.com> ---
(In reply to Martin Nowak from comment #1)
> A bit more reduced, but I don't understand enough of the
> addMember/include/scope part of dmd to fix this.

At that line in attrib.c, the assert checks that the StaticIfDeclaration is
correctly recognizing the enclosing ScopeDsymbol (it's set in the preceding
addMember pass), and eventually checks the order of semantic analysis passes is
correct (the condition evaluation must happen after that addMember pass
completion).

But, current __traits(allMembers) iterates the members of yet not instantiated
templates, and it violates dmd internal invariants for forward reference
resolution.

Minimized test case;

struct Typedef
{
    template opDispatch(string name)
    {
        static if (true)   // __traits(allMembers) must not visit here
        {
        }
    }
}

bool runUnitTestsImpl()
{
    foreach (M; __traits(allMembers, Typedef.opDispatch))
    {
    }
    return true;
}

--


More information about the Digitalmars-d-bugs mailing list