CertainLach / jrsonnet

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

`no super found` under certain conditions #153

Closed davidreuss closed 6 months ago

davidreuss commented 6 months ago

Hi 👋

Currently looking at jrsonnet for potential major performance gains (likely a ~10x) in a project at work, and i've isolated a snippet of code which works using regular jsonnet interpreter but fails using jrsonnet.

I've boiled it down to the below snippet,

local upper = {
  'bar': if 'baz' in super then super.baz else 'nope',
};

local obj = {
  foo+: upper,
};

obj

Which when evaluated crashes and errors out with

❯ jrsonnet super.jsonnet
no super found
    super.jsonnet:2:10-55: if condition
    field <bar> manifestification
    field <foo> manifestification

While go-jsonnet implementation works just fine

❯ jsonnet super.jsonnet
{
   "foo": {
      "bar": "nope"
   }
}

It also works with sjsonnet

❯ java -jar sjsonnet-0.4.9.jar super.jsonnet
{
   "foo": {
      "bar": "nope"
   }
}

Now i am not currently able to spend the amount of time that it would take to understand this problem in relation to the rust implementation, and i will likely be looking for a different way of writing the code once i find a reasonable workaround.

But in the meantime, i just wanted to let you know about this issue, if this project is still alive and kicking, in which case -- there's hope for our current performance issues, which we're having with the go jsonnet implementation, and very likely requires a subtantial effort in restructuring/rewriting to get out of. So sprinkling some 🪄 interpreter as a possible workaround for a few applications would go a long way in relieving ourselves from a world of pain 😂

CertainLach commented 6 months ago

I see, if name in super should not fail if super is not exists, it should be easy to fix