From d426e80c73aaa169c528ff54335376511d3c1cea Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 12 Oct 2022 15:54:43 +0200 Subject: [PATCH] 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 --- elab_expr.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elab_expr.cc b/elab_expr.cc index 0c9c330aa..28e7ce643 100644 --- a/elab_expr.cc +++ b/elab_expr.cc @@ -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);