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:
parent
a8eda65859
commit
cdb9bc2c21
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue