mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Merge remote-tracking branch 'origin/topic/vern/GH-3191'
* origin/topic/vern/GH-3191: BTests for any/vector-of-any fixes fixes for vector assignments involving "any"/"vector of any" types
This commit is contained in:
commit
de65671a0a
8 changed files with 66 additions and 4 deletions
6
CHANGES
6
CHANGES
|
@ -1,3 +1,9 @@
|
||||||
|
6.1.0-dev.331 | 2023-08-25 21:38:40 +0200
|
||||||
|
|
||||||
|
* BTests for any/vector-of-any fixes (Vern Paxson, Corelight)
|
||||||
|
|
||||||
|
* fixes for vector assignments involving "any"/"vector of any" types (Vern Paxson, Corelight)
|
||||||
|
|
||||||
6.1.0-dev.327 | 2023-08-24 12:17:42 -0700
|
6.1.0-dev.327 | 2023-08-24 12:17:42 -0700
|
||||||
|
|
||||||
* updated notes regarding "-O gen-C++" maintenance (Vern Paxson, Corelight)
|
* updated notes regarding "-O gen-C++" maintenance (Vern Paxson, Corelight)
|
||||||
|
|
2
NEWS
2
NEWS
|
@ -61,6 +61,8 @@ New Functionality
|
||||||
|
|
||||||
- Added new packet analyzer to handle PCAP files DLT_PPP link type.
|
- Added new packet analyzer to handle PCAP files DLT_PPP link type.
|
||||||
|
|
||||||
|
- Fixed appending of ``any`` to ``vector of any``.
|
||||||
|
|
||||||
Changed Functionality
|
Changed Functionality
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
6.1.0-dev.327
|
6.1.0-dev.331
|
||||||
|
|
|
@ -814,7 +814,8 @@ ValPtr BinaryExpr::Fold(Val* v1, Val* v2) const
|
||||||
if ( t1->Tag() == TYPE_VECTOR )
|
if ( t1->Tag() == TYPE_VECTOR )
|
||||||
{
|
{
|
||||||
// We only get here when using a matching vector on the RHS.
|
// We only get here when using a matching vector on the RHS.
|
||||||
v2->AsVectorVal()->AddTo(v1, false);
|
if ( ! v2->AsVectorVal()->AddTo(v1, false) )
|
||||||
|
Error("incompatible vector element assignment", v2);
|
||||||
return {NewRef{}, v1};
|
return {NewRef{}, v1};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1683,7 +1684,9 @@ AddToExpr::AddToExpr(ExprPtr arg_op1, ExprPtr arg_op2)
|
||||||
|
|
||||||
else if ( IsVector(bt1) )
|
else if ( IsVector(bt1) )
|
||||||
{
|
{
|
||||||
if ( same_type(t1, t2) )
|
// We need the IsVector(bt2) check in the following because
|
||||||
|
// same_type() always treats "any" types as "same".
|
||||||
|
if ( IsVector(bt2) && same_type(t1, t2) )
|
||||||
{
|
{
|
||||||
SetType(t1);
|
SetType(t1);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -3726,7 +3726,8 @@ bool VectorVal::AddTo(Val* val, bool /* is_first_init */) const
|
||||||
auto last_idx = v->Size();
|
auto last_idx = v->Size();
|
||||||
|
|
||||||
for ( auto i = 0u; i < Size(); ++i )
|
for ( auto i = 0u; i < Size(); ++i )
|
||||||
v->Assign(last_idx++, At(i));
|
if ( ! v->Assign(last_idx++, At(i)) )
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
error in <...>/vector-any-append.zeek, line 61: incompatible vector element assignment (v7 += v5 and [a, -3])
|
|
@ -1,2 +1,7 @@
|
||||||
### 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.
|
||||||
[0, 1, 2, 3]
|
[0, 1, 2, 3]
|
||||||
|
[4, 0, 1, 2, 3]
|
||||||
|
[1, 2, 3, [4, 5]], 4, count, count, vector of count
|
||||||
|
[[r=r], [r=r], [s=s], [s=s]]
|
||||||
|
[a, -3]
|
||||||
|
[]
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# @TEST-EXEC: zeek -b %INPUT >out
|
# @TEST-EXEC: zeek -b %INPUT >out
|
||||||
# @TEST-EXEC: btest-diff out
|
# @TEST-EXEC: btest-diff out
|
||||||
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff .stderr
|
||||||
|
|
||||||
function assign(v: vector of any)
|
function assign(v: vector of any)
|
||||||
{
|
{
|
||||||
|
@ -11,6 +12,17 @@ function append(v: vector of any)
|
||||||
v += |v|;
|
v += |v|;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type R: record { r: string &default="r"; };
|
||||||
|
type S: record { s: string &default="s"; };
|
||||||
|
|
||||||
|
global q: vector of any;
|
||||||
|
|
||||||
|
function keep_this_two_ways(r: any)
|
||||||
|
{
|
||||||
|
q += r;
|
||||||
|
q[|q|] = r;
|
||||||
|
}
|
||||||
|
|
||||||
event zeek_init()
|
event zeek_init()
|
||||||
{
|
{
|
||||||
local v: vector of count;
|
local v: vector of count;
|
||||||
|
@ -19,4 +31,35 @@ event zeek_init()
|
||||||
append(v);
|
append(v);
|
||||||
append(v);
|
append(v);
|
||||||
print v;
|
print v;
|
||||||
|
|
||||||
|
local v2: vector of any;
|
||||||
|
v2 += |v|;
|
||||||
|
v2 += v;
|
||||||
|
print v2;
|
||||||
|
|
||||||
|
local v3: vector of any;
|
||||||
|
local v4: any = vector(4, 5);
|
||||||
|
|
||||||
|
v3 += 1;
|
||||||
|
v3 += vector(2, 3);
|
||||||
|
v3 += v4;
|
||||||
|
|
||||||
|
print v3, |v3|, type_name(v3[0]), type_name(v3[1]), type_name(v3[3]);
|
||||||
|
|
||||||
|
keep_this_two_ways(R());
|
||||||
|
keep_this_two_ways(S());
|
||||||
|
print q;
|
||||||
|
|
||||||
|
local v5: vector of any;
|
||||||
|
local v6: vector of any;
|
||||||
|
local v7: vector of count;
|
||||||
|
|
||||||
|
v5 += "a";
|
||||||
|
v5 += -3;
|
||||||
|
|
||||||
|
v6 += v5;
|
||||||
|
v7 += v5;
|
||||||
|
|
||||||
|
print v6;
|
||||||
|
print v7;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue