mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Fix &ordered
attribute not preserved in table initializer assignments
This commit is contained in:
parent
fd98958b92
commit
074faf202f
5 changed files with 58 additions and 1 deletions
|
@ -142,7 +142,7 @@ static ExprPtr initialize_var(const IDPtr& id, InitClass c, ExprPtr init) {
|
||||||
ExprPtr assignment;
|
ExprPtr assignment;
|
||||||
|
|
||||||
if ( c == INIT_FULL )
|
if ( c == INIT_FULL )
|
||||||
assignment = make_intrusive<AssignExpr>(lhs, init, false);
|
assignment = make_intrusive<AssignExpr>(lhs, init, false, nullptr, id->GetAttrs());
|
||||||
else if ( c == INIT_EXTRA )
|
else if ( c == INIT_EXTRA )
|
||||||
assignment = make_intrusive<AddToExpr>(lhs, init);
|
assignment = make_intrusive<AddToExpr>(lhs, init);
|
||||||
else if ( c == INIT_REMOVE )
|
else if ( c == INIT_REMOVE )
|
||||||
|
|
|
@ -23,3 +23,21 @@ copy(ordered_sset)
|
||||||
3
|
3
|
||||||
4
|
4
|
||||||
5
|
5
|
||||||
|
ordered_sset2
|
||||||
|
foo
|
||||||
|
bar
|
||||||
|
baz
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
5
|
||||||
|
copy(ordered_sset2)
|
||||||
|
foo
|
||||||
|
bar
|
||||||
|
baz
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
5
|
||||||
|
|
|
@ -1,7 +1,16 @@
|
||||||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
tbl
|
||||||
2
|
2
|
||||||
1
|
1
|
||||||
3
|
3
|
||||||
|
tbl2
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
tbl3
|
||||||
|
4
|
||||||
|
5
|
||||||
|
6
|
||||||
1
|
1
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
|
|
|
@ -4,6 +4,12 @@
|
||||||
|
|
||||||
global sset: set[string];
|
global sset: set[string];
|
||||||
global ordered_sset: set[string] &ordered;
|
global ordered_sset: set[string] &ordered;
|
||||||
|
global ordered_sset2: set[string] = {
|
||||||
|
"foo",
|
||||||
|
"bar",
|
||||||
|
} &ordered &redef;
|
||||||
|
|
||||||
|
redef ordered_sset2 += { "baz" };
|
||||||
|
|
||||||
event zeek_init()
|
event zeek_init()
|
||||||
{
|
{
|
||||||
|
@ -12,6 +18,7 @@ event zeek_init()
|
||||||
{
|
{
|
||||||
add sset[cat(i)];
|
add sset[cat(i)];
|
||||||
add ordered_sset[cat(i)];
|
add ordered_sset[cat(i)];
|
||||||
|
add ordered_sset2[cat(i)];
|
||||||
}
|
}
|
||||||
|
|
||||||
print "sset";
|
print "sset";
|
||||||
|
@ -29,4 +36,12 @@ event zeek_init()
|
||||||
print "copy(ordered_sset)";
|
print "copy(ordered_sset)";
|
||||||
for ( s in copy(ordered_sset) )
|
for ( s in copy(ordered_sset) )
|
||||||
print s;
|
print s;
|
||||||
|
|
||||||
|
print "ordered_sset2";
|
||||||
|
for ( s in ordered_sset2 )
|
||||||
|
print s;
|
||||||
|
|
||||||
|
print "copy(ordered_sset2)";
|
||||||
|
for ( s in copy(ordered_sset2) )
|
||||||
|
print s;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,12 @@
|
||||||
|
|
||||||
global tbl: table[count] of count;
|
global tbl: table[count] of count;
|
||||||
global tbl2: table[count] of count &ordered;
|
global tbl2: table[count] of count &ordered;
|
||||||
|
global tbl3: table[count] of count = {
|
||||||
|
[4] = 4,
|
||||||
|
[5] = 5,
|
||||||
|
} &ordered &redef;
|
||||||
|
|
||||||
|
redef tbl3 += { [6] = 6 };
|
||||||
|
|
||||||
event zeek_init()
|
event zeek_init()
|
||||||
{
|
{
|
||||||
|
@ -13,15 +19,24 @@ event zeek_init()
|
||||||
++i;
|
++i;
|
||||||
tbl[i] = i;
|
tbl[i] = i;
|
||||||
tbl2[i] = i;
|
tbl2[i] = i;
|
||||||
|
tbl3[i] = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print "tbl";
|
||||||
for ( [k], v in tbl )
|
for ( [k], v in tbl )
|
||||||
{
|
{
|
||||||
print(v);
|
print(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print "tbl2";
|
||||||
for ( [k], v in tbl2 )
|
for ( [k], v in tbl2 )
|
||||||
{
|
{
|
||||||
print(v);
|
print(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print "tbl3";
|
||||||
|
for ( [k], v in tbl3 )
|
||||||
|
{
|
||||||
|
print(v);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue