mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Change table initialization deprecation to error
This commit is contained in:
parent
a105b26692
commit
d5b19c61ff
6 changed files with 7 additions and 26 deletions
13
src/Var.cc
13
src/Var.cc
|
@ -195,18 +195,7 @@ static void make_var(const IDPtr& id, TypePtr t, InitClass c, ExprPtr init,
|
|||
{
|
||||
// This can happen because the grammar allows any "init_class",
|
||||
// including none, to be followed by an expression.
|
||||
// Remove in v6.1 (make an error)
|
||||
reporter->Deprecation(
|
||||
util::fmt("Remove in v6.1. Initialization not preceded by =/+=/-= is deprecated. (%s)",
|
||||
obj_desc_short(init.get()).c_str()),
|
||||
init->GetLocationInfo());
|
||||
|
||||
// The historical instances of these, such as the
|
||||
// language/redef-same-prefixtable-idx.zeek btest, treat
|
||||
// this as += rather than =, and with the initializer
|
||||
// implicitly inside a list.
|
||||
init = make_intrusive<ListExpr>(init);
|
||||
c = INIT_EXTRA;
|
||||
init->Error("Initialization not preceded by =/+=/-= is not allowed.");
|
||||
}
|
||||
|
||||
if ( init && init->Tag() == EXPR_LIST )
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
error in <...>/init-mismatch.zeek, line 6: invalid constructor list on RHS of assignment (a = 3, 5)
|
||||
error in <...>/init-mismatch.zeek, line 6: assignment of non-arithmetic value to arithmetic (count/types) (a = 3, 5)
|
||||
warning in <...>/init-mismatch.zeek, line 7: Remove in v6.1. Initialization not preceded by =<...>/-= is deprecated. (4, 6)
|
||||
error in <...>/init-mismatch.zeek, line 7: Initialization not preceded by =<...>/-= is not allowed. (4, 6)
|
||||
error in <...>/init-mismatch.zeek, line 13: different number of indices (list of count,count and list of count,count,count)
|
||||
error in <...>/init-mismatch.zeek, line 14: table constructor element lacks '=' structure (bar)
|
||||
error in <...>/init-mismatch.zeek, line 17: empty list in untyped initialization ()
|
||||
|
|
|
@ -1,3 +1 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
warning in <...>/redef-same-prefixtable-idx.zeek, line 7: Remove in v6.1. Initialization not preceded by =<...>/-= is deprecated. (3.0.0.0/8 = 1.0.0.0/8)
|
||||
warning in <...>/redef-same-prefixtable-idx.zeek, line 8: Remove in v6.1. Initialization not preceded by =<...>/-= is deprecated. (3.0.0.0/8 = 2.0.0.0/8)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
{
|
||||
[abc] = 8.0,
|
||||
[abc] = 42.0,
|
||||
[neat] = 1.0,
|
||||
[cool] = 28.0,
|
||||
[cool] = 5.0,
|
||||
[def] = 99.0
|
||||
}
|
||||
|
|
|
@ -4,12 +4,8 @@
|
|||
|
||||
const my_table: table[subnet] of subnet &redef;
|
||||
|
||||
redef my_table[3.0.0.0/8] = 1.0.0.0/8;
|
||||
redef my_table[3.0.0.0/8] = 2.0.0.0/8;
|
||||
|
||||
# The above is basically a shorthand for:
|
||||
# redef my_table += { [3.0.0.0/8] = 1.0.0.0/8 };
|
||||
# redef my_table += { [3.0.0.0/8] = 2.0.0.0/8 };
|
||||
redef my_table += { [3.0.0.0/8] = 1.0.0.0/8 };
|
||||
redef my_table += { [3.0.0.0/8] = 2.0.0.0/8 };
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
|
|
|
@ -18,9 +18,7 @@ redef foo -= { ["ghi"] = 0.0 };
|
|||
# RHS can be a table value
|
||||
redef foo += table(["cool"] = 5.0, ["neat"] = 1.0);
|
||||
|
||||
# Redef at a single index is allowed, same as += when RHS has overlapping index
|
||||
redef foo["cool"] = 28.0;
|
||||
redef foo["abc"] = 8.0;
|
||||
# redef a single element using +=
|
||||
redef foo += { ["def"] = 99.0 };
|
||||
|
||||
print foo;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue