From 2d5ecb01ba52741612479d085f1e1aecc710d0c5 Mon Sep 17 00:00:00 2001 From: Noah Treuhaft Date: Mon, 16 Dec 2024 17:27:24 -0500 Subject: [PATCH] Don't wrap errors in vector put operator (#5536) The sequence put operator passes errors along unmodified while the vector operator wraps them inside another error. Make the vector implementation behave like the sequence implementation. --- runtime/vam/expr/putter.go | 5 ++++- runtime/ztests/op/put-non-record.yaml | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/runtime/vam/expr/putter.go b/runtime/vam/expr/putter.go index 918fd6a10a..3330fcd4b4 100644 --- a/runtime/vam/expr/putter.go +++ b/runtime/vam/expr/putter.go @@ -23,7 +23,10 @@ func (p *Putter) Eval(vec vector.Any) vector.Any { func (p *Putter) eval(vecs ...vector.Any) vector.Any { vec := vecs[0] - if vec.Type().Kind() != super.RecordKind { + if k := vec.Type().Kind(); k != super.RecordKind { + if k == super.ErrorKind { + return vec + } return vector.NewWrappedError(p.zctx, "put: not a record", vec) } return p.recordExpr.Eval(vec) diff --git a/runtime/ztests/op/put-non-record.yaml b/runtime/ztests/op/put-non-record.yaml index f205713ce4..dc86e53a52 100644 --- a/runtime/ztests/op/put-non-record.yaml +++ b/runtime/ztests/op/put-non-record.yaml @@ -4,6 +4,8 @@ vector: true input: | 0 + error("kaboom") output: | error({message:"put: not a record",on:0}) + error("kaboom")