Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sjsonnet allows computed imports unlike go-jsonnet #138

Closed
nicklan opened this issue Nov 16, 2021 · 2 comments · Fixed by #153
Closed

sjsonnet allows computed imports unlike go-jsonnet #138

nicklan opened this issue Nov 16, 2021 · 2 comments · Fixed by #153

Comments

@nicklan
Copy link
Contributor

nicklan commented Nov 16, 2021

Sample file:

local i = import "a" + import "b";
0

go-jsonnet:

$ jsonnet foo.jsonnet
foo.jsonnet:1:18-34 Computed imports are not allowed

local i = import "a" + import "b";

sjsonnet:

$ sjsonnet foo.jsonnet
0
@szeiger
Copy link
Collaborator

szeiger commented Aug 31, 2022

This looks like a precedence problem. import should have lower precedence than + but Sjsonnet treats it as higher. We see the same for . (local buiApiServerReleasePipeline = import "./release-pipeline.jsonnet.TEMPLATE".buiApiServerReleasePipeline;)

@szeiger
Copy link
Collaborator

szeiger commented Sep 1, 2022

From https://jsonnet.org/ref/spec.html:

Everything is left associative. In the case of assert, error, function, if, import, importstr, and local, ambiguity is resolved by consuming as many tokens as possible on the right hand side.

But the grammar contains

import string

and this is what Sjsonnet implements. The intention is probably to parse as import expr and then assert that the expr is a string.

szeiger added a commit to szeiger/sjsonnet that referenced this issue Sep 1, 2022
Fixes databricks#138

The spec is not very clear on this but this behavior is consistent with the C++ and Go implementations.
szeiger added a commit to szeiger/sjsonnet that referenced this issue Sep 1, 2022
Fixes databricks#138

The spec is not very clear on this but this behavior is consistent with the C++ and Go implementations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants