gkz / LiveScript

LiveScript is a language which compiles to JavaScript. It has a straightforward mapping to JavaScript and allows you to write expressive code devoid of repetitive boilerplate. While LiveScript adds many features to assist in functional style programming, it also has many improvements for object oriented and imperative programming.
http://livescript.net
MIT License
2.31k stars 156 forks source link

`in` doesn't work inside of `case` or `|` guards of implicit `for..in` loops #1039

Closed pepkin88 closed 6 years ago

pepkin88 commented 6 years ago

Examples causing a compilation error:

for arr case .. in [1 2] => 1
for arr | v in b => 1
[1 for arr case .. in [1 2]]

Working examples:

for arr case (.. in [1 2]) => 1
for arr when .. in [1 2] => 1
for n in a case n in [1 2] => 1
for til 3 | .. in b => 1

It seems that affected are only implicit for..in loops (for array) with guards with the in keyword inside and only when using case or | as a guard keyword, not when. Wrapping the guard's condition with parentheses also mitigates the issue.

Possibly related to #923 (#925).