mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 07:38:19 +00:00
Merge remote-tracking branch 'origin/topic/timw/1740-table-key-error'
* origin/topic/timw/1740-table-key-error: GH-1741: Print error if calling a non-hook with hook keyword GH-1740: Report a better error message if table key is not a list
This commit is contained in:
commit
7a6a81c200
6 changed files with 31 additions and 11 deletions
|
@ -2626,7 +2626,7 @@ TypePtr AssignExpr::InitType() const
|
|||
{
|
||||
if ( op1->Tag() != EXPR_LIST )
|
||||
{
|
||||
Error("bad initializer");
|
||||
Error("bad initializer, first operand should be a list");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -3490,7 +3490,10 @@ TableConstructorExpr::TableConstructorExpr(ListExprPtr constructor_list,
|
|||
SetType(init_type(op.get()));
|
||||
|
||||
if ( ! type )
|
||||
{
|
||||
SetError();
|
||||
return;
|
||||
}
|
||||
|
||||
else if ( type->Tag() != TYPE_TABLE || type->AsTableType()->IsSet() )
|
||||
SetError("values in table(...) constructor do not specify a table");
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue