jrsonnet
jrsonnet copied to clipboard
Destructuring bind default values can't be overriden
This works fine:
local {a = 1} = {};
a
Result:
1
But this doesn't:
local {a = 1} = {a: 3};
a
Error:
runtime error: too many fields, and rest not found
<string>:3:9-11: variable <a> access
Is this intended? Or is it a bug?
I figured out that if I do this, it will work properly:
local {a = 1, ...} = {a: 3};
a
Result:
3
I don't thinks this is intuitive or documented anywhere.
Yep, looks like a bug. Destructuring system is not being tested much, I'll look into it.
@CertainLach @simonrouse9461 But this will not get a valid result in jsonnet.
local {a = 1} = {};
a
gives me :
Error: example1.jsonnet:1:7-8 Expected token IDENTIFIER but got "{"
local {a = 1} = {};