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

adjacent object literals vs adjacent variables #1110

Open
dcopso opened this issue Sep 8, 2023 · 2 comments
Open

adjacent object literals vs adjacent variables #1110

dcopso opened this issue Sep 8, 2023 · 2 comments

Comments

@dcopso
Copy link

dcopso commented Sep 8, 2023

I'm new to jsonnet and I'm loving it but I see a behavior that I'm surprised by: the + between object literals seems to be optional, but only on object literals:

This program is valid:

{a:1} {b:1}

This program is not:

local left = {a:1};
local right = {b:1};
left right

Changing left right to left + right makes the program valid.

This suggests that variables are not transparent in the same way that functions are. Is this expected?

Also, what is going on with {a:1} {b:1}? Why is that, and expressions such as {}{}, valid?

Thanks!

@dcopso
Copy link
Author

dcopso commented Sep 9, 2023

This has also been raised in the discussion forum: https://groups.google.com/g/jsonnet/c/RoJIt5vlwX4

@CertainLach
Copy link
Contributor

This is sugar for object coming right after any other expression, it desugars to a + b

Relevant part of the specification:
$desugar_{expr}(e { objinside }, b) = desugar_{expr}(e + { objinside }, b)$

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

No branches or pull requests

2 participants