Added interpreter error for local event variables.

Scheduling a local event variable resulted in a global lookup instead of
evaluating the local variable. To prevent misunderstandings, this will
trigger an error now.
This commit is contained in:
Jan Grashoefer 2016-05-11 12:26:11 +02:00
parent cc54b3772a
commit 65607239c9
5 changed files with 35 additions and 7 deletions

View file

@ -1474,11 +1474,20 @@ event:
TOK_ID '(' opt_expr_list ')'
{
set_location(@1, @4);
$$ = new EventExpr($1, $3);
ID* id = lookup_ID($1, current_module.c_str());
if ( id && id->IsDeprecated() )
reporter->Warning("deprecated (%s)", id->Name());
ID* id = lookup_ID($1, current_module.c_str());
if ( id )
{
if ( ! id->IsGlobal() )
{
yyerror(fmt("local identifier \"%s\" cannot be used to reference an event", $1));
YYERROR;
}
if ( id->IsDeprecated() )
reporter->Warning("deprecated (%s)", id->Name());
}
$$ = new EventExpr($1, $3);
}
;