From b4d92f7bb91ba09d754e144b55760159930efefc Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 4 Aug 2026 00:54:25 -0700 Subject: [PATCH] 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 --- elab_expr.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/elab_expr.cc b/elab_expr.cc index e76d5f063..561f7a24e 100644 --- a/elab_expr.cc +++ b/elab_expr.cc @@ -3340,9 +3340,12 @@ NetExpr* PECallFunction::elaborate_expr_(Design*des, NetScope*scope, use_search_results.scope = scope; 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.net = scope->find_signal(perm_string::literal(THIS_TOKEN)); - use_search_results.type = use_search_results.net->net_type(); + NetScope *method_scope = find_method_containing_scope(*this, scope); + 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); + use_search_results.type = use_search_results.net->net_type(); return elaborate_expr_method_(des, scope, use_search_results); }