mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
splicing to the end of a one-time expression.
This commit is contained in:
parent
813a5f1e1f
commit
2d54a45a80
3 changed files with 14 additions and 2 deletions
|
@ -1225,7 +1225,7 @@
|
|||
}
|
||||
}
|
||||
} else {
|
||||
to = "" + name + ".length";
|
||||
to = "9e9";
|
||||
}
|
||||
val = this.value.compile(o);
|
||||
return "[].splice.apply(" + name + ", [" + fromDecl + ", " + to + "].concat(" + val + "))";
|
||||
|
|
|
@ -982,7 +982,7 @@ exports.Assign = class Assign extends Base
|
|||
to = to.compile(o) + ' - ' + fromRef
|
||||
to += ' + 1' unless exclusive
|
||||
else
|
||||
to = "#{name}.length"
|
||||
to = "9e9"
|
||||
val = @value.compile(o)
|
||||
"[].splice.apply(#{name}, [#{fromDecl}, #{to}].concat(#{val}))"
|
||||
|
||||
|
|
|
@ -163,3 +163,15 @@ test "splicing with expressions as endpoints", ->
|
|||
ary = [0..9]
|
||||
ary[a+1...2*b+1] = [4]
|
||||
arrayEq [0, 1, 4, 7, 8, 9], ary
|
||||
|
||||
test "splicing to the end, against a one-time function", ->
|
||||
ary = null
|
||||
fn = ->
|
||||
if ary
|
||||
throw 'err'
|
||||
else
|
||||
ary = [1, 2, 3]
|
||||
|
||||
fn()[0..] = 1
|
||||
|
||||
arrayEq ary, [1]
|
||||
|
|
Loading…
Add table
Reference in a new issue