Find implicit `this` in the containing class method

An unqualified method call inside a named block is elaborated from the block
scope. When the call resolves to another method in the same class, receiver
construction looks for the implicit `this` signal directly in that scope:

    function int call_method();
      begin : nested
        return get_value();
      end
    endfunction

The signal belongs to the containing method scope, so the lookup returns null
and the compiler dereferences it.

Find the containing method first and obtain the implicit `this` signal from
that scope.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2026-08-04 00:54:25 -07:00
parent c71709d75d
commit b4d92f7bb9
1 changed files with 5 additions and 2 deletions

View File

@ -3340,9 +3340,12 @@ NetExpr* PECallFunction::elaborate_expr_(Design*des, NetScope*scope,
use_search_results.scope = scope; use_search_results.scope = scope;
use_search_results.path_tail.push_back(search_results.path_head.back()); use_search_results.path_tail.push_back(search_results.path_head.back());
use_search_results.path_head.push_back(name_component_t(perm_string::literal(THIS_TOKEN))); use_search_results.path_head.push_back(name_component_t(perm_string::literal(THIS_TOKEN)));
use_search_results.net = scope->find_signal(perm_string::literal(THIS_TOKEN)); NetScope *method_scope = find_method_containing_scope(*this, scope);
use_search_results.type = use_search_results.net->net_type(); ivl_assert(*this, method_scope);
use_search_results.net = method_scope->find_signal(
perm_string::literal(THIS_TOKEN));
ivl_assert(*this, use_search_results.net); ivl_assert(*this, use_search_results.net);
use_search_results.type = use_search_results.net->net_type();
return elaborate_expr_method_(des, scope, use_search_results); return elaborate_expr_method_(des, scope, use_search_results);
} }