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

--- Comment #2 from Iain Buclaw <[email protected]> ---
In `templateInstanceSemantic`, there is a shortcut for merging multiple
template instantiations originating from the same template decl.  It fixes up
the `minst` Module of the first instantiation to point at the root module
instead of a non-root module.

However, the first instantiation ran `tryExpandMembers`, which had set the
`_scope.minst` of all Dsymbol members to the non-root module.  This is left
intact despite their parent instance being updated.

Why is it important to note this?  In the event of handling forward references,
all further template instantiations from are pushed into that non-root module
that came from `_scope.minst`.  It is this that leads to undefined references
in both the mtype and func modules, they should have been pushed to the root
module, but `_scope.minst` is now incorrectly set.

A patch I am preparing for this adds a new Visitor to walk over all members and
update their `_scope.minst` to be the root module.

--

Reply via email to