Closed folliehiyuki closed 1 year ago
Strange enough the line [if salted then 'garnish']: 'Salt',
renders fine in the tree:
local Margarita(salted) = {
ingredients: [
{ kind: 'Tequila Blanco', qty: 2 },
],
[if salted then 'garnish']: 'Salt',
};
{
Margarita: Margarita(true),
'Margarita Unsalted': Margarita(false),
}
The inspected node tree:
(expr) ; [1:1 - 10:1]
(local_bind) ; [1:1 - 10:1]
(local) ; [1:1 - 5]
(bind) ; [1:7 - 6:1]
function: (id) ; [1:7 - 15]
params: (params) ; [1:17 - 22]
(param) ; [1:17 - 22]
identifier: (id) ; [1:17 - 22]
body: (expr) ; [1:27 - 6:1]
(member) ; [2:3 - 4:3]
(field) ; [2:3 - 4:3]
(fieldname) ; [2:3 - 13]
(id) ; [2:3 - 13]
(expr) ; [2:16 - 4:3]
(expr) ; [3:5 - 38]
(member) ; [3:7 - 28]
(field) ; [3:7 - 28]
(fieldname) ; [3:7 - 10]
(id) ; [3:7 - 10]
(expr) ; [3:13 - 28]
(string) ; [3:13 - 28]
(string_start) ; [3:13 - 13]
(string_content) ; [3:14 - 27]
(string_end) ; [3:28 - 28]
(member) ; [3:31 - 36]
(field) ; [3:31 - 36]
(fieldname) ; [3:31 - 33]
(id) ; [3:31 - 33]
(expr) ; [3:36 - 36]
(number) ; [3:36 - 36]
(member) ; [5:3 - 36]
(field) ; [5:3 - 36]
(fieldname) ; [5:3 - 28]
(expr) ; [5:4 - 27]
condition: (expr) ; [5:7 - 12]
(id) ; [5:7 - 12]
consequence: (expr) ; [5:19 - 27]
(string) ; [5:19 - 27]
(string_start) ; [5:19 - 19]
(string_content) ; [5:20 - 26]
(string_end) ; [5:27 - 27]
(expr) ; [5:31 - 36]
(string) ; [5:31 - 36]
(string_start) ; [5:31 - 31]
(string_content) ; [5:32 - 35]
(string_end) ; [5:36 - 36]
(expr) ; [7:1 - 10:1]
(member) ; [8:3 - 28]
(field) ; [8:3 - 28]
(fieldname) ; [8:3 - 11]
(id) ; [8:3 - 11]
(expr) ; [8:14 - 28]
(expr) ; [8:14 - 22]
(id) ; [8:14 - 22]
(args) ; [8:24 - 27]
(expr) ; [8:24 - 27]
(true) ; [8:24 - 27]
(member) ; [9:3 - 40]
(field) ; [9:3 - 40]
(fieldname) ; [9:3 - 22]
(string) ; [9:3 - 22]
(string_start) ; [9:3 - 3]
(string_content) ; [9:4 - 21]
(string_end) ; [9:22 - 22]
(expr) ; [9:25 - 40]
(expr) ; [9:25 - 33]
(id) ; [9:25 - 33]
(args) ; [9:35 - 39]
(expr) ; [9:35 - 39]
(false) ; [9:35 - 39]
So I assume it's only detected as ERROR when it is the first key in the map object.
Looks like I'm handling this in #15, let me add your examples as tests.
Test cases pass. :tada:
Thanks for spending the time fixing my issue!
I think in the 2nd example you should put [if salted then 'garnish']
as the 1st key of the object, since in the current state it only fails to render in that situation.
A valid jsonnet file (shorten from https://jsonnet.org/learning/tutorial.html#parameterize-entire-config):
The json output (using
go-jsonnet
v0.20.0):Here is the tree nodes, taken from Neovim's
vim.treesitter.inspect_tree()
: