From f35515ac656c387aea724947b5f920a64b251e5f Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sat, 15 Aug 2026 21:01:05 -0700 Subject: [PATCH] symbol_search(): Track compilation-unit search explicitly The scope traversal clears `start_scope` after switching to the compilation unit and uses the null value to prevent a second compilation-unit search. This gives the scope used for path evaluation two separate purposes. Track whether the compilation-unit scope has been searched with a separate flag. Keep the existing instance-before-compilation-unit traversal order. Signed-off-by: Lars-Peter Clausen --- symbol_search.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/symbol_search.cc b/symbol_search.cc index e5bc034f8..afff1bb44 100644 --- a/symbol_search.cc +++ b/symbol_search.cc @@ -321,6 +321,9 @@ bool symbol_search(const LineInfo*li, Design*des, NetScope*scope, if (start_scope==0) start_scope = scope; + NetScope *unit_scope = start_scope->unit(); + bool searched_unit_scope = false; + // If there are components ahead of the tail, symbol_search // recursively. Ideally, the result is a scope that we search // for the tail key, but there are other special cases as well. @@ -500,9 +503,9 @@ bool symbol_search(const LineInfo*li, Design*des, NetScope*scope, // ... = ok; // This reference is OK // ... = not_ok; // This reference is NOT OK. // endmodule - if (scope == 0 && start_scope != 0) { - scope = start_scope->unit(); - start_scope = 0; + if (scope == nullptr && !searched_unit_scope) { + scope = unit_scope; + searched_unit_scope = true; search_objects = true; } }