From 3a10f1277a15d7e85dcac2b9f3b0429e755948da Mon Sep 17 00:00:00 2001 From: Noah Treuhaft Date: Wed, 25 Mar 2026 19:01:20 -0400 Subject: [PATCH] fix defuse() bug on record field with union type --- runtime/sam/expr/function/defuse.go | 2 +- runtime/ztests/expr/function/defuse.yaml | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/runtime/sam/expr/function/defuse.go b/runtime/sam/expr/function/defuse.go index 08080be6f..24f272367 100644 --- a/runtime/sam/expr/function/defuse.go +++ b/runtime/sam/expr/function/defuse.go @@ -49,7 +49,7 @@ func (d *defuse) eval(in super.Value) super.Value { fields = append(fields, super.NewField(f.Name, val.Type())) } b.EndContainerWithNones(typ.Opts, nones) - return super.NewValue(d.sctx.MustLookupTypeRecord(fields), b.Bytes()) + return super.NewValue(d.sctx.MustLookupTypeRecord(fields), b.Bytes().Body()) case *super.TypeArray: elems := d.parseArrayOrSet(typ.Type, in.Bytes()) if len(elems) == 0 { diff --git a/runtime/ztests/expr/function/defuse.yaml b/runtime/ztests/expr/function/defuse.yaml index 2822eee1e..0a393f993 100644 --- a/runtime/ztests/expr/function/defuse.yaml +++ b/runtime/ztests/expr/function/defuse.yaml @@ -34,3 +34,13 @@ input: &input | error(1::=er1)::=er2 output: *input + +--- + +spq: defuse(this) + +input: | + {a:fusion(1::(int64|string),)} + +output: | + {a:1}