[Issue 21299] [LINK] undefined reference to dmd.root.stringtable.StringValue!(Type).StringValue.lstring()

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Oct 8 23:20:40 UTC 2020


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

--- Comment #1 from Iain Buclaw <ibuclaw at gdcproject.org> ---
What looks to be the reason for the issue:

struct StringTable(T)
{
    StringValue!T* insert()
        fwdrefs -> 
            allocValue;
            getValue;

    uint allocValue()
        instantiates ->
            StringValue!(T)

    StringValue!T* getValue()
}

1. StringTable!(Type) is having semantic ran from 'dmd.mtype' scope.
2. All members have semantic ran in order of declaration using mtype scope.
3. allocValue is a forward reference inside insert(), so functionSemantic3() is
called, which switches to using _scope member, which is the scope of the first
instantiation context (not the current) 'dmd.func'.
4. allocValue instantiates StringValue!(Type) using func scope.
5. StringValue!(Type) is appended to the non-root module 'dmd.func', and so not
emitted.

-------------

Swap the insert() and allocValue() members around though, and the execution
path becomes:

1. StringTable!(Type) is having semantic ran from 'dmd.mtype' scope.
2. All members have semantic ran in order of declaration using mtype scope.
3. allocValue instantiates StringValue!(Type) using mtype scope.
4. StringValue!(Type) is appended to the root module 'dmd.mtype', so is
emitted.

-------------

Immediately then, the problem may be one of:

- functionSemantic()/functionSemantic3() doesn't accept a Scope parameter, so
the context that they are being evaluated in is lost.   They should be fixed to
accept a Scope parameter.

- The _scope of a function is not updated if a second instantiation occurs in a
root module.

--


More information about the Digitalmars-d-bugs mailing list