mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 00:58:19 +00:00
fixes for vector assignments involving "any"/"vector of any" types
This commit is contained in:
parent
ae03d591b8
commit
d70a0fae85
2 changed files with 7 additions and 3 deletions
|
@ -814,7 +814,8 @@ ValPtr BinaryExpr::Fold(Val* v1, Val* v2) const
|
|||
if ( t1->Tag() == TYPE_VECTOR )
|
||||
{
|
||||
// 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};
|
||||
}
|
||||
|
||||
|
@ -1683,7 +1684,9 @@ AddToExpr::AddToExpr(ExprPtr arg_op1, ExprPtr arg_op2)
|
|||
|
||||
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);
|
||||
return;
|
||||
|
|
|
@ -3726,7 +3726,8 @@ bool VectorVal::AddTo(Val* val, bool /* is_first_init */) const
|
|||
auto last_idx = v->Size();
|
||||
|
||||
for ( auto i = 0u; i < Size(); ++i )
|
||||
v->Assign(last_idx++, At(i));
|
||||
if ( ! v->Assign(last_idx++, At(i)) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue