Fix typedef derived from type defined inside interface (#3441) (#6776)

This commit is contained in:
em2machine
2025-12-08 15:36:21 -05:00
committed by GitHub
parent 7e55c62cac
commit d0a5da2445
25 changed files with 707 additions and 37 deletions
+5 -5
View File
@@ -5309,18 +5309,18 @@ class LinkDotResolveVisitor final : public VNVisitor {
const VSymEnt* foundp;
if (nodep->classOrPackagep()) {
foundp = m_statep->getNodeSym(nodep->classOrPackagep())->findIdFlat(nodep->name());
} else if (!nodep->ifacePortName().empty()) { // Interface typedef
nodep->v3error("Unsupported: SystemVerilog 2005 interface typedef");
return;
} else if (m_ds.m_dotPos == DP_FIRST || m_ds.m_dotPos == DP_NONE) {
foundp = m_curSymp->findIdFallback(nodep->name());
} else {
//foundp = m_curSymp->findIdFlat(nodep->name());
// Use dotSymp if set (e.g., for captured interface typedefs), else curSymp
VSymEnt* const lookupSymp = m_ds.m_dotSymp ? m_ds.m_dotSymp : m_curSymp;
foundp = lookupSymp->findIdFlat(nodep->name());
}
if (!foundp && ifaceCaptured && capturedTypedefp) {
if (ifaceCaptured && capturedTypedefp) {
// When we have a captured interface typedef context, use the captured typedef
// instead of any local lookup result. This handles the case where the local
// typedef has the same name as the interface typedef (e.g., `typedef if0.rq_t
// rq_t;`)
UINFO(9, indent() << "iface capture binding via captured typedef fallback name="
<< nodep->name() << " typedef=" << capturedTypedefp);
nodep->typedefp(capturedTypedefp);