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

Add ability to include code in --tla-code and --tla-code-file #175

Merged
merged 8 commits into from Jun 6, 2023

Conversation

lihaoyi-databricks
Copy link
Contributor

@lihaoyi-databricks lihaoyi-databricks commented Jun 6, 2023

Similar to the --ext-code changes in #171, --tla-code is meant to be able to take arbitrary Jsonnet code just like --ext-code can, and before this PR we limited it to only JSON

I refactored out the common Interpreter#parseVar logic so it can be shared between both, and added new tests to exercise the new behavior.

The override def evalDefault for the Val.Func used for top-level functions needed to be fixed; there was always a logical issue evaluating the --tla-code expression using the main file's ValScope, but it didn't matter since previously we only allowed JSON so there weren't any identifiers to look up using it. Now that there are, the correct thing to do is to evaluate the --tla-code expression using ValScope.empty, since it is meant to be a standalone expression without any existing local bindings in its lexical scope

Notably, --tla-code expressions cannot reference each other the way --ext-code expressions can, so there is no equivalent to the stdExtVarRecursive test case. They can still call std functions, so the std test case remains

@lihaoyi-databricks lihaoyi-databricks merged commit 3a3e252 into master Jun 6, 2023
1 check passed
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 this pull request may close these issues.

None yet

2 participants