Catch if &add_func/&delete_func is applied to IDs that don't have values.

We do to allow adding &add_func to a global that's not immediately
initialized, as a later redef may fix that.

Closes #467.
This commit is contained in:
Robin Sommer 2020-08-18 10:31:16 +00:00
parent 5816ea27e9
commit 45bef16be0
3 changed files with 24 additions and 0 deletions

View file

@ -220,6 +220,13 @@ void ID::SetVal(ExprPtr ev, InitClass c)
if ( ! a )
Internal("no add/delete function in ID::SetVal");
if ( ! val )
{
Error(fmt("%s initializer applied to ID without value",
(c == INIT_EXTRA ? "+=" : "-="), this);
return;
}
EvalFunc(a->GetExpr(), std::move(ev));
}