Fix error reporting when calling task in an expression

Calling a task as part of an expression should report an error. The current
implementation uses `func_def()` and if that returns nullptr will report
the error. But `func_def()` will trigger an assert if the underlying scope
is not a function.

Make sure to first check that the scope is actually a function before
trying to call `func_def()`. If the scope is not a function report an
error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2022-10-12 15:54:43 +02:00
parent abc26eeaeb
commit d426e80c73
1 changed files with 2 additions and 2 deletions

View File

@ -2709,8 +2709,7 @@ NetExpr* PECallFunction::elaborate_expr_(Design*des, NetScope*scope,
}
// If the symbol is found, but is not a _function_ scope...
NetFuncDef*def = search_results.scope->func_def();
if (def == 0) {
if (search_results.scope->type() != NetScope::FUNC) {
// Not a user defined function. Maybe it is an access
// function for a nature? If so then elaborate it that
// way.
@ -2725,6 +2724,7 @@ NetExpr* PECallFunction::elaborate_expr_(Design*des, NetScope*scope,
des->errors += 1;
return 0;
}
NetFuncDef*def = search_results.scope->func_def();
ivl_assert(*this, def);
ivl_assert(*this, def->scope() == search_results.scope);