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 <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2026-08-15 21:01:05 -07:00
parent 4e425289bb
commit f35515ac65
1 changed files with 6 additions and 3 deletions

View File

@ -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;
}
}