diff --git a/src/Expr.cc b/src/Expr.cc index 6513cacecb..c741e65938 100644 --- a/src/Expr.cc +++ b/src/Expr.cc @@ -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; diff --git a/src/Val.cc b/src/Val.cc index f8aa0c6309..cea41553dd 100644 --- a/src/Val.cc +++ b/src/Val.cc @@ -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; }