From 7b68f5d532520b6c9efa2b426f284b79c20fe1e8 Mon Sep 17 00:00:00 2001 From: Akash Levy Date: Wed, 27 May 2026 03:55:03 -0700 Subject: [PATCH] Revert "Remove nested $fork handling from union detection" This reverts commit 10a4056e3bd50b52771c0bf5a059cba7f5a3bb15. --- kernel/fstdata.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/kernel/fstdata.cc b/kernel/fstdata.cc index da3f7ee23..e1b66b873 100644 --- a/kernel/fstdata.cc +++ b/kernel/fstdata.cc @@ -175,6 +175,26 @@ void FstData::extractVarNames() while ((h = fstReaderIterateHier(ctx))) { switch (h->htyp) { + case FST_HT_SCOPE: { + // Handle tracking for potential union structs with $fork. + if (!detect_union && h->u.scope.typ == FST_ST_VCD_FORK) { + detect_union = true; + fork_parent_scope = fst_scope_name; + fork_name = h->u.scope.name; + fork_vars.clear(); + } else if (detect_union && h->u.scope.typ == FST_ST_VCD_STRUCT) { + // Signal that a nested $fork can not be a candidate for union struct detection. + log_warning("Nested $fork '%s' inside $fork '%s'; " + "abandoning union detection for this scope...\n", + h->u.scope.name, fork_name.c_str()); + for (auto &v : fork_vars) registerVar(v); + detect_union = false; + fork_vars.clear(); + } + // Push the scope onto the stack to 'descend' into the hierarchy. + fst_scope_name = fstReaderPushScope(ctx, h->u.scope.name, NULL); + break; + } case FST_HT_SCOPE: { // Handle tracking for potential union structs with $fork. if (!detect_union && h->u.scope.typ == FST_ST_VCD_FORK) {