mirror of
https://github.com/zeek/zeek.git
synced 2025-10-11 11:08:20 +00:00
Fix redef of table index from clearing table. Addresses #1013.
`redef foo["x"] = 1` now acts like `redef foo += { ["x"] = 1 }` instead of `redef foo = { ["x"] = 1 }`.
This commit is contained in:
parent
f811e669ff
commit
ae5a75bad9
3 changed files with 38 additions and 0 deletions
|
@ -156,6 +156,12 @@ static void make_var(ID* id, BroType* t, init_class c, Expr* init,
|
|||
|
||||
if ( do_init )
|
||||
{
|
||||
if ( c == INIT_NONE && dt == VAR_REDEF && t->IsTable() &&
|
||||
init && init->Tag() == EXPR_ASSIGN )
|
||||
// e.g. 'redef foo["x"] = 1' is missing an init class, but the
|
||||
// intention clearly isn't to overwrite entire existing table val.
|
||||
c = INIT_EXTRA;
|
||||
|
||||
if ( (c == INIT_EXTRA && id->FindAttr(ATTR_ADD_FUNC)) ||
|
||||
(c == INIT_REMOVE && id->FindAttr(ATTR_DEL_FUNC)) )
|
||||
// Just apply the function.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue