Fix bug incorrect dereferencing rest argument (#5810)
* Fix bug incorrect dereferencing rest argument * Fix pure path * Minor refactor
This commit is contained in:
@@ -2,5 +2,5 @@ function first() {
|
||||
var _ref;
|
||||
|
||||
var index = 0;
|
||||
return _ref = index++, arguments.length <= _ref ? undefined : arguments[_ref];
|
||||
return _ref = index++, _ref < 0 || arguments.length <= _ref ? undefined : arguments[_ref];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
function f(a, ...rest) {
|
||||
let b = rest[rest.length - 3];
|
||||
let c = rest[rest.length - 2];
|
||||
let d = rest[rest.length - 1];
|
||||
return [a, b, c, d];
|
||||
}
|
||||
|
||||
function f(a, ...rest) {
|
||||
return rest[-1];
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
function f1(a, ...rest) {
|
||||
let b = rest[rest.length - 3];
|
||||
let c = rest[rest.length - 2];
|
||||
let d = rest[rest.length - 1];
|
||||
return [a, b, c, d];
|
||||
}
|
||||
assert.deepEqual(f1(1, 2), [1, undefined, undefined, 2])
|
||||
|
||||
function f2(a, ...rest) {
|
||||
return rest[-1];
|
||||
}
|
||||
assert.equal(f2(1, 2), undefined)
|
||||
@@ -0,0 +1,12 @@
|
||||
function f(a) {
|
||||
var _ref, _ref2, _ref3;
|
||||
|
||||
var b = (_ref = (arguments.length <= 1 ? 0 : arguments.length - 1) - 3 + 1, _ref < 1 || arguments.length <= _ref ? undefined : arguments[_ref]);
|
||||
var c = (_ref2 = (arguments.length <= 1 ? 0 : arguments.length - 1) - 2 + 1, _ref2 < 1 || arguments.length <= _ref2 ? undefined : arguments[_ref2]);
|
||||
var d = (_ref3 = (arguments.length <= 1 ? 0 : arguments.length - 1) - 1 + 1, _ref3 < 1 || arguments.length <= _ref3 ? undefined : arguments[_ref3]);
|
||||
return [a, b, c, d];
|
||||
}
|
||||
|
||||
function f(a) {
|
||||
return void 0;
|
||||
}
|
||||
@@ -2,7 +2,7 @@ var t = function (f) {
|
||||
var _ref;
|
||||
|
||||
arguments.length <= 1 ? undefined : arguments[1];
|
||||
_ref = (arguments.length <= 1 ? 0 : arguments.length - 1) - 1 + 1, arguments.length <= _ref ? undefined : arguments[_ref];
|
||||
_ref = (arguments.length <= 1 ? 0 : arguments.length - 1) - 1 + 1, _ref < 1 || arguments.length <= _ref ? undefined : arguments[_ref];
|
||||
};
|
||||
|
||||
function t(f) {
|
||||
|
||||
Reference in New Issue
Block a user