jrsonnet icon indicating copy to clipboard operation
jrsonnet copied to clipboard

std.mergePatch evaluates object

Open Duologic opened this issue 8 months ago • 4 comments

This snippet works differently compared to go-jsonnet/c-jsonnet:

std.mergePatch({ val: error 'should not error' }, {}) + { val+:: {} }
➜ jsonnet -e "std.mergePatch({ val: error 'should not error' }, {}) + { val+:: {} }"
{ }

➜ jrsonnet -e "std.mergePatch({ val: error 'should not error' }, {}) + { val+:: {} }"
runtime error: should not error
    <cmdline>:1:23-48: error statement
    <cmdline>:1:1-55:  function <builtin_merge_patch> call

Duologic avatar Apr 23 '25 17:04 Duologic

what about the sjsonnet?

He-Pin avatar Apr 23 '25 18:04 He-Pin

what about the sjsonnet?

java -jar sjsonnet.jar -e "std.mergePatch({ val: error 'should not error' }, {}) + { val+:: {} }"
sjsonnet.Error: should not error
    at [Error].(<exec>:1:23)
    at [std.mergePatch].(<exec>:1:15)
    at [BinaryOp +].(<exec>:1:55)

It also errors

JarvisCraft avatar Apr 24 '25 01:04 JarvisCraft