mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
improve elision output (#4824)
This commit is contained in:
parent
5eb9dded52
commit
b1286752b9
3 changed files with 8 additions and 4 deletions
|
@ -3626,7 +3626,10 @@
|
|||
subpattern: true
|
||||
}).compileToFragments(o, LEVEL_LIST));
|
||||
} else {
|
||||
assigns.push(idx.compileToFragments(o, LEVEL_LIST));
|
||||
if (expandedIdx) {
|
||||
// Output `Elision` only if `idx` is `i++`, e.g. expandedIdx.
|
||||
assigns.push(idx.compileToFragments(o, LEVEL_LIST));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!(top || this.subpattern)) {
|
||||
|
|
|
@ -2472,7 +2472,8 @@ exports.Assign = class Assign extends Base
|
|||
unless obj instanceof Elision
|
||||
assigns.push new Assign(obj, val, null, param: @param, subpattern: yes).compileToFragments o, LEVEL_LIST
|
||||
else
|
||||
assigns.push idx.compileToFragments o, LEVEL_LIST
|
||||
# Output `Elision` only if `idx` is `i++`, e.g. expandedIdx.
|
||||
assigns.push idx.compileToFragments o, LEVEL_LIST if expandedIdx
|
||||
|
||||
assigns.push vvar unless top or @subpattern
|
||||
fragments = @joinFragmentArrays assigns, ', '
|
||||
|
|
|
@ -74,8 +74,8 @@ test "array elisions destructuring with splats and expansions", ->
|
|||
arrayEq [a,b], [2,[5,6,7,8,9]]
|
||||
[,c,...,,d,,e] = arr
|
||||
arrayEq [c,d,e], [2,7,9]
|
||||
[...,e,,,f,,,] = arr
|
||||
arrayEq [e,f], [4,7]
|
||||
[...,f,,,g,,,] = arr
|
||||
arrayEq [f,g], [4,7]
|
||||
|
||||
test "array elisions as function parameters", ->
|
||||
arr = [1,2,3,4,5,6,7,8,9]
|
||||
|
|
Loading…
Add table
Reference in a new issue