diff --git a/runtime/vam/expr/arith.go b/runtime/vam/expr/arith.go index 7cc28b77a8..8eecfdf7fc 100644 --- a/runtime/vam/expr/arith.go +++ b/runtime/vam/expr/arith.go @@ -29,6 +29,12 @@ func (a *Arith) Eval(val vector.Any) vector.Any { func (a *Arith) eval(vecs ...vector.Any) (out vector.Any) { lhs := enumToIndex(vector.Under(vecs[0])) rhs := enumToIndex(vector.Under(vecs[1])) + if vector.KindOf(lhs) == vector.KindError { + return lhs + } + if vector.KindOf(rhs) == vector.KindError { + return rhs + } lhs, rhs, errVal := coerceVals(a.zctx, lhs, rhs) if errVal != nil { return errVal diff --git a/runtime/ztests/expr/arith-errors.yaml b/runtime/ztests/expr/arith-errors.yaml new file mode 100644 index 0000000000..19fc69df5a --- /dev/null +++ b/runtime/ztests/expr/arith-errors.yaml @@ -0,0 +1,13 @@ +zed: yield s/0 + +vector: true + +input: | + {} + {s:error("other")} + {s:1} + +output: | + error("missing") + error("other") + error("divide by zero")