CertainLach/jrsonnet

Referring to earlier arguments in function argument default value expressions

gurer-kensho opened this issue · 1 comments

First of all, thank you very much for this excellent implementation!

I have found a behavior difference between the official jsonnet and your implementation. It isn't a big deal, as it isn't great practice to have complex expressions in the default values anyway but I'd like to report it.

Given the input:

{
  f(a,b=a+1,c=b+1):: ( a + b + c ),
  x: self.f(1),
  y: self.f(1, b=10),
}

Official jsonnet renders:

{
  "x": 6,
  "y": 22
}

but Jrsonnet gives:

variable is not defined: a

General expressions and references to other defined variables work in the default value expressions, so I speculate this is only about the previous argument value not being visible in the expressions for b and c.

Note that the official jsonnet doesn't do it dynamically and always uses the value calculated at the time of the function definition which can be seen in the 'y' output.

Feel free to close it if you think this is just an artifact of the official implementation and doesn't worth supporting.

Please ignore, just found #59