GH-1741: Print error if calling a non-hook with hook keyword

This commit is contained in:
Tim Wojtulewicz 2021-12-08 14:08:54 -07:00
parent c15a9eab7f
commit b966a3876f
3 changed files with 20 additions and 9 deletions

View file

@ -721,8 +721,12 @@ expr:
{
--in_hook;
set_location(@1, @3);
if ( $3->Tag() != EXPR_CALL )
$3->Error("not a valid hook call expression");
else if ( $3->AsCallExpr()->Func()->GetType()->AsFuncType()->Flavor() != FUNC_FLAVOR_HOOK )
$3->Error("hook keyword should only be used to call hooks");
$$ = $3;
}