From cdb9bc2c215efa728eafca981f1985eb84463653 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 11 May 2026 08:39:25 -0700 Subject: [PATCH 1/2] Reject `super` access without a parent class The `super` keyword refers to the parent class of the current class. If the class has no parent the lookup still returned the current class handle and left the `super` path component for l-value elaboration. This triggered the `tail_path.empty()` assert. Report an error during symbol lookup instead. Signed-off-by: Lars-Peter Clausen --- symbol_search.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/symbol_search.cc b/symbol_search.cc index 61a28d4ec..255d608c4 100644 --- a/symbol_search.cc +++ b/symbol_search.cc @@ -153,6 +153,15 @@ bool symbol_search(const LineInfo*li, Design*des, NetScope*scope, if (path_tail.name == "#") { if (NetNet *net = scope->find_signal(perm_string::literal(THIS_TOKEN))) { const netclass_t *class_type = dynamic_cast(net->net_type()); + ivl_assert(*li, class_type); + if (!class_type->get_super()) { + cerr << li->get_fileline() << ": error: " + << "Class " << class_type->get_name() + << " uses `super` without a base class." + << endl; + des->errors += 1; + return false; + } path.push_back(path_tail); res->scope = scope; res->net = net; From e4afd6dc25c940a7b85d552ddd4d067568fa56ca Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 11 May 2026 08:52:09 -0700 Subject: [PATCH 2/2] Add regression test for `super` access error Check that access through `super` is rejected when the current class has no parent class. Signed-off-by: Lars-Peter Clausen --- ivtest/ivltests/sv_super_member_fail.v | 11 +++++++++++ ivtest/regress-vvp.list | 1 + ivtest/vvp_tests/sv_super_member_fail.json | 5 +++++ 3 files changed, 17 insertions(+) create mode 100644 ivtest/ivltests/sv_super_member_fail.v create mode 100644 ivtest/vvp_tests/sv_super_member_fail.json diff --git a/ivtest/ivltests/sv_super_member_fail.v b/ivtest/ivltests/sv_super_member_fail.v new file mode 100644 index 000000000..503c1131d --- /dev/null +++ b/ivtest/ivltests/sv_super_member_fail.v @@ -0,0 +1,11 @@ +// Check that `super` access in a class without a parent class is rejected. + +module test; + + class C; + function void f; + super.x = 1; + endfunction + endclass + +endmodule diff --git a/ivtest/regress-vvp.list b/ivtest/regress-vvp.list index 8424d7f55..5671edaf5 100644 --- a/ivtest/regress-vvp.list +++ b/ivtest/regress-vvp.list @@ -288,6 +288,7 @@ sv_package_lifetime vvp_tests/sv_package_lifetime.json sv_package_lifetime_fail vvp_tests/sv_package_lifetime_fail.json sv_parameter_type vvp_tests/sv_parameter_type.json sv_queue_assign_op vvp_tests/sv_queue_assign_op.json +sv_super_member_fail vvp_tests/sv_super_member_fail.json sv_wildcard_import8 vvp_tests/sv_wildcard_import8.json sdf_header vvp_tests/sdf_header.json task_return1 vvp_tests/task_return1.json diff --git a/ivtest/vvp_tests/sv_super_member_fail.json b/ivtest/vvp_tests/sv_super_member_fail.json new file mode 100644 index 000000000..14a7e7d70 --- /dev/null +++ b/ivtest/vvp_tests/sv_super_member_fail.json @@ -0,0 +1,5 @@ +{ + "type" : "CE", + "source" : "sv_super_member_fail.v", + "iverilog-args" : [ "-g2005-sv" ] +}