Thread overview
[Issue 14844] dmd-2.068.0-b2 attrib.c:1233: virtual Dsymbols* StaticIfDeclaration::include(Scope*, ScopeDsymbol*): Assertion `scopesym' failed
Jul 28, 2015
Martin Nowak
Jul 28, 2015
Martin Nowak
[Issue 14844] [REG2.068a] __traits(allMembers) must not visit yet not instantiated template members
Jul 29, 2015
Kenji Hara
Jul 29, 2015
Kenji Hara
Jul 29, 2015
wikodes@gmail.com
July 28, 2015
https://issues.dlang.org/show_bug.cgi?id=14844

Martin Nowak <code@dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice
                 CC|                            |code@dawg.eu

--
July 28, 2015
https://issues.dlang.org/show_bug.cgi?id=14844

--- Comment #1 from Martin Nowak <code@dawg.eu> ---
A bit more reduced, but I don't understand enough of the addMember/include/scope part of dmd to fix this.

module app;

import std.typecons;

alias CppNs = Typedef!string;

bool runUnitTestsImpl(alias COMPOSITE)() {
    foreach (M; __traits(allMembers, COMPOSITE))
        static if (__traits(compiles, __traits(getMember, COMPOSITE, M))
                   && !isModule!(__traits(getMember, COMPOSITE, M)))
            if (runUnitTestsImpl!(__traits(getMember, COMPOSITE, M)))
                return false;
    return true;
}

template isModule(alias DECL) {
    enum isModule = startsWith(DECL.stringof, "module ");
}

bool startsWith(Needle)(string doesThisStart, Needle withThis)
{
    return doesThisStart.length >= withThis.length &&
        doesThisStart[0 .. withThis.length] == withThis;
}

alias run = runUnitTestsImpl!app;

--
July 29, 2015
https://issues.dlang.org/show_bug.cgi?id=14844

Kenji Hara <k.hara.pg@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@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;
}

--
July 29, 2015
https://issues.dlang.org/show_bug.cgi?id=14844

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> ---
https://github.com/D-Programming-Language/dmd/pull/4846

--
July 29, 2015
https://issues.dlang.org/show_bug.cgi?id=14844

--- Comment #4 from wikodes@gmail.com ---
Amazing response. The speed and quality!
Good job :)

--
July 30, 2015
https://issues.dlang.org/show_bug.cgi?id=14844

--- Comment #5 from github-bugzilla@puremagic.com ---
Commits pushed to stable at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/9e6ad65840b86acc7406f30704e898366bb93cb8
fix Issue 14844 - __traits(allMembers) must not visit yet not instantiated
template members

https://github.com/D-Programming-Language/dmd/commit/d69289bb56952a1e259fd2e6f07b8b7d4fad9d16 Merge pull request #4846 from 9rnsr/fix14844

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

--
August 05, 2015
https://issues.dlang.org/show_bug.cgi?id=14844

--- Comment #6 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/9e6ad65840b86acc7406f30704e898366bb93cb8
fix Issue 14844 - __traits(allMembers) must not visit yet not instantiated
template members

https://github.com/D-Programming-Language/dmd/commit/d69289bb56952a1e259fd2e6f07b8b7d4fad9d16 Merge pull request #4846 from 9rnsr/fix14844

--