You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ cabal run hs-jsonnet -- -e '[x for x in [1,2,3] if x > 1 if x < 3]'
1:30:
|
1 | [x forxin [1,2,3] if x > 1 if x < 3]
| ^
unexpected 'i'
expecting "!=", "&&", "<<", "<=", "==", ">=", ">>", "for", "in", "||", '%', '&', '(', '*', '+', '-', '/', '<', '>', '[', ']', '^', '|', ., or object
Expected output
$ jsonnet -e '[x for x in [1,2,3] if x > 1 if x < 3]'
[
2
]
The problem
In our implementation, the ifspecs are parsed as an optional part of forspecs. This only allows a singular ifspec to be allowed per forspec. However, the Jsonnet specification allows an array comprehension to contain any number of compspecs after an initial mandatory forspec, where compspecs can be either forspecs orifspecs.
The text was updated successfully, but these errors were encountered:
Thanks for reporting! We can have nested forspecs, as done here, but the way we are doing it now, the ifspec is optional and goes attached to the forspec. I guess we could change that so that to have a list of ifspecs. The way I implemented this is a bit different from how it's specified.
std.assertEqual(obj, { ["f" + x + y + z]: { x: x, y: y, z: z } for x in [1, 2, 3] for y in [1, 4, 6] if x + 2 < y for z in [true, false] })
Minimal way to reproduce
Expected output
$ jsonnet -e '[x for x in [1,2,3] if x > 1 if x < 3]' [ 2 ]
The problem
In our implementation, the
ifspec
s are parsed as an optional part offorspec
s. This only allows a singularifspec
to be allowed perforspec
. However, the Jsonnet specification allows an array comprehension to contain any number ofcompspec
s after an initial mandatoryforspec
, wherecompspec
s can be eitherforspec
s orifspec
s.The text was updated successfully, but these errors were encountered: