Fix #2953. Method calls on splice endpoints
This commit is contained in:
parent
fd61476106
commit
e7ebdce60f
|
@ -1746,7 +1746,7 @@
|
||||||
fromDecl = fromRef = '0';
|
fromDecl = fromRef = '0';
|
||||||
}
|
}
|
||||||
if (to) {
|
if (to) {
|
||||||
if ((from != null ? from.isSimpleNumber() : void 0) && to.isSimpleNumber()) {
|
if (from && from instanceof Value && (from != null ? from.isSimpleNumber() : void 0) && to instanceof Value && to.isSimpleNumber()) {
|
||||||
to = +to.compile(o) - +fromRef;
|
to = +to.compile(o) - +fromRef;
|
||||||
if (!exclusive) {
|
if (!exclusive) {
|
||||||
to += 1;
|
to += 1;
|
||||||
|
|
|
@ -1261,7 +1261,8 @@ exports.Assign = class Assign extends Base
|
||||||
else
|
else
|
||||||
fromDecl = fromRef = '0'
|
fromDecl = fromRef = '0'
|
||||||
if to
|
if to
|
||||||
if from?.isSimpleNumber() and to.isSimpleNumber()
|
if from and from instanceof Value and from?.isSimpleNumber() and
|
||||||
|
to instanceof Value and to.isSimpleNumber()
|
||||||
to = +to.compile(o) - +fromRef
|
to = +to.compile(o) - +fromRef
|
||||||
to += 1 unless exclusive
|
to += 1 unless exclusive
|
||||||
else
|
else
|
||||||
|
|
|
@ -144,3 +144,12 @@ test "#1723: operator precedence in unbounded splice compilation", ->
|
||||||
list = [0..9]
|
list = [0..9]
|
||||||
list[..if n then n else 0] = n
|
list[..if n then n else 0] = n
|
||||||
arrayEq [n..9], list
|
arrayEq [n..9], list
|
||||||
|
|
||||||
|
test "#2953: methods on endpoints in assignment from array splice literal", ->
|
||||||
|
list = [0..9]
|
||||||
|
|
||||||
|
Number.prototype.same = -> this
|
||||||
|
list[1.same()...9.same()] = 5
|
||||||
|
delete Number.prototype.same
|
||||||
|
|
||||||
|
arrayEq [0, 5, 9], list
|
||||||
|
|
Loading…
Reference in New Issue