diff --git a/ucl/builtins/strs_test.go b/ucl/builtins/strs_test.go index 9545e0c..3fc4cf6 100644 --- a/ucl/builtins/strs_test.go +++ b/ucl/builtins/strs_test.go @@ -140,17 +140,17 @@ func TestStrs_Split(t *testing.T) { want any wantErr bool }{ - {desc: "split 1", eval: `strs:split "1,2,3" ","`, want: ucl.StringListObject{"1", "2", "3"}}, - {desc: "split 2", eval: `strs:split "1,2,3" ";"`, want: ucl.StringListObject{"1,2,3"}}, - {desc: "split 3", eval: `strs:split "" ";"`, want: ucl.StringListObject{""}}, - {desc: "split 4", eval: `strs:split " " ";"`, want: ucl.StringListObject{" "}}, + {desc: "split 1", eval: `strs:split "1,2,3" ","`, want: []string{"1", "2", "3"}}, + {desc: "split 2", eval: `strs:split "1,2,3" ";"`, want: []string{"1,2,3"}}, + {desc: "split 3", eval: `strs:split "" ";"`, want: []string{""}}, + {desc: "split 4", eval: `strs:split " " ";"`, want: []string{" "}}, - {desc: "split by char 1", eval: `strs:split "123"`, want: ucl.StringListObject{"1", "2", "3"}}, + {desc: "split by char 1", eval: `strs:split "123"`, want: []string{"1", "2", "3"}}, - {desc: "split max 1", eval: `strs:split "1,2,3" "," -max 2`, want: ucl.StringListObject{"1", "2,3"}}, - {desc: "split max 2", eval: `strs:split "1,2,3" "," -max 5`, want: ucl.StringListObject{"1", "2", "3"}}, + {desc: "split max 1", eval: `strs:split "1,2,3" "," -max 2`, want: []string{"1", "2,3"}}, + {desc: "split max 2", eval: `strs:split "1,2,3" "," -max 5`, want: []string{"1", "2", "3"}}, - {desc: "split by char max 1", eval: `strs:split "12345" -max 3`, want: ucl.StringListObject{"1", "2", "345"}}, + {desc: "split by char max 1", eval: `strs:split "12345" -max 3`, want: []string{"1", "2", "345"}}, {desc: "err 1", eval: `strs:split "1,2,3" -max []`, wantErr: true}, } diff --git a/ucl/inst.go b/ucl/inst.go index 74dbdcf..e47873f 100644 --- a/ucl/inst.go +++ b/ucl/inst.go @@ -151,7 +151,7 @@ func (inst *Inst) Eval(ctx context.Context, expr string) (any, error) { goRes, ok := toGoValue(res) if !ok { - return nil, ErrNotConvertable + return res, nil } return goRes, nil @@ -207,7 +207,7 @@ func (n nativePseudoVarHandler) set(ctx context.Context, name string, v Object) gv, ok := toGoValue(v) if !ok { - return errors.New("cannot set non-matching type") + return mpvh.Set(ctx, v) } return mpvh.Set(ctx, gv) @@ -233,7 +233,7 @@ func (n nativeMissingPseudoVarHandler) set(ctx context.Context, name string, v O gv, ok := toGoValue(v) if !ok { - return errors.New("cannot set non-matching type") + return mpvh.Set(ctx, name, v) } return mpvh.Set(ctx, name, gv)