Skip to content

Commit

Permalink
vam: Propagate errors in arith exprs
Browse files Browse the repository at this point in the history
  • Loading branch information
mattnibs committed Feb 10, 2025
1 parent 90c1f36 commit 0301ffd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions runtime/vam/expr/arith.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions runtime/ztests/expr/arith-errors.yaml
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit 0301ffd

Please sign in to comment.