From 895ab8789b61050c3048256e745853c9a9b0e87d Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 18 Mar 2023 17:11:39 -0400 Subject: [PATCH] Internals: Fix recently added assertion false firing --- src/V3Task.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/V3Task.cpp b/src/V3Task.cpp index ea12eb5f3..a46b8932a 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -673,19 +673,25 @@ private: void unlinkAndClone(AstNodeFTask* funcp, AstNode* nodep, bool withNext) { UASSERT_OBJ(nodep, funcp, "null in function object clone"); - VNRelinker relinkHandle; - if (withNext) { - nodep->unlinkFrBackWithNext(&relinkHandle); - } else { - nodep->unlinkFrBack(&relinkHandle); - } if (funcp->recursive()) { + VNRelinker relinkHandle; + if (withNext) { + nodep->unlinkFrBackWithNext(&relinkHandle); + } else { + nodep->unlinkFrBack(&relinkHandle); + } // Recursive functions require the original argument list to // still be live for linking purposes. // The old function gets clone, so that node pointers are mostly // retained through the V3Task transformations AstNode* const newp = nodep->cloneTree(withNext); relinkHandle.relink(newp); + } else { + if (withNext) { + nodep->unlinkFrBackWithNext(); + } else { + nodep->unlinkFrBack(); + } } }