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 <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2026-05-11 08:39:25 -07:00
parent a8eda65859
commit cdb9bc2c21
1 changed files with 9 additions and 0 deletions

View File

@ -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<const netclass_t*>(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;