CertainLach / jrsonnet

Rust implementation of Jsonnet language
MIT License
290 stars 33 forks source link

Destructuring bind default values can't be overriden #170

Open simonrouse9461 opened 2 weeks ago

simonrouse9461 commented 2 weeks ago

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?

simonrouse9461 commented 2 weeks ago

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.

CertainLach commented 2 weeks ago

Yep, looks like a bug. Destructuring system is not being tested much, I'll look into it.