Skip to content

Commit

Permalink
fix in in case guarding implicit for..in
Browse files Browse the repository at this point in the history
  • Loading branch information
rhendric committed Apr 27, 2018
1 parent 6a5b97c commit a8f23f5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
3 changes: 1 addition & 2 deletions lib/lexer.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions src/lexer.ls
Expand Up @@ -212,7 +212,6 @@ exports <<<
| last.0 is '(' => 'BIOP'
| otherwise => 'WITH'
case 'when'
@fset 'for' false
tag = 'CASE'
fallthrough
case 'case'
Expand Down Expand Up @@ -467,9 +466,9 @@ exports <<<
@last.spaced = true if input = SPACE.exec(code).0
input.length

# Used from both do-literal (|) and do-ID (case): adds swtich if required
# Used from both do-literal (|) and do-ID (case): adds switch if required
do-case: ->
@seen-for = false
@fset 'for' false
if @last.0 in <[ ASSIGN -> : ]>
or (@last.0 is 'INDENT' and @tokens[*-2].0 in <[ ASSIGN -> : ]>)
@token 'SWITCH' 'switch'
Expand Down
13 changes: 13 additions & 0 deletions test/loop.ls
Expand Up @@ -743,3 +743,16 @@ throws "Cannot read property 'length' of undefined" -> [0 for x in void]

# [LiveScript#1035](https://github.com/gkz/LiveScript/issues/1035)
for [1 2 3] then 1 else 0

# [LiveScript#1039](https://github.com/gkz/LiveScript/issues/1039)
arr = [3 2 1 0]
x = for arr case .. in [1 2] => 1
eq '1,1' x.join \,

v = 1
b = [1]
x = for arr | v in b => 1
eq '1,1,1,1' x.join \,

x = [1 for arr case .. in [1 2]]
eq '1,1' x.join \,

0 comments on commit a8f23f5

Please sign in to comment.