Karl Cheng 0667160b11 Fix optimisation of shadowed rest parameters
The arguments of a function would be unnecessarily copied if there was
a nested function that had a parameter with the same identifier as the
rest parameter for the outer function. This checks the scope of the
parameter is correct before deoptimising.

Fixes: https://github.com/babel/babel/issues/5656
Refs: https://github.com/babel/babel/issues/2091
2017-05-16 22:39:13 +10:00

30 lines
503 B
JavaScript

function a() {
var foo = function () {
return bar.apply(undefined, arguments);
};
foo.apply(undefined, arguments);
}
function b() {
var foo = function () {
return bar.apply(undefined, arguments);
};
foo.apply(undefined, arguments);
}
function c() {
var foo = function () {
return bar.apply(undefined, arguments);
};
foo([]);
}
function d(thing) {
var foo = function () {
return bar.apply(undefined, arguments);
};
{
var _args = thing;
foo(thing);
}
}