Skip to content

Commit

Permalink
Merge pull request #860 from summivox/fix-empty-splat
Browse files Browse the repository at this point in the history
Fix #858 Inconsistent empty splat assignment
  • Loading branch information
vendethiel committed Mar 2, 2016
2 parents 382c7b7 + f18a91c commit 62a8eb5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/ast.ls
Original file line number Diff line number Diff line change
Expand Up @@ -1660,10 +1660,14 @@ class exports.Assign extends Node
continue if skip and i+2 is len
start = i+1
@temps = [ivar = o.scope.temporary \i]
val = if skip then node = Var ivar; Var val else
Arr.wrap JS "#i < (#ivar = #val)
\ ? #{ util \slice }.call(#rite, #i, #ivar)
\ : (#ivar = #i, [])"
val = switch
| skip
Arr.wrap JS "#i < (#ivar = #val) ? #i : (#ivar = #i)"
| _
Arr.wrap JS do
"#i < (#ivar = #val)
\ ? #{ util \slice }.call(#rite, #i, #ivar)
\ : (#ivar = #i, [])"
else
(inc = ivar) and start < i and inc += " + #{ i - start }"
val = Chain rcache||=Literal(rite), [Index JS inc || i]
Expand Down
6 changes: 6 additions & 0 deletions test/splat.ls
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ eq b, 2
eq a, 1
eq b, 5

# [LiveScript#858](https://github.com/gkz/LiveScript/issues/858)
[a, ..., b, c, d] = [1 2 3]
eq a, 1
eq b, 2
eq c, 3

eq '''
(function(){
var a;
Expand Down

0 comments on commit 62a8eb5

Please sign in to comment.