Don't resolve shadowed arguments variables from functions (#14036)
This commit is contained in:
parent
dfcfbf3b27
commit
add64e870b
@ -1,7 +1,7 @@
|
||||
var _arguments2 = 1;
|
||||
|
||||
function fn() {
|
||||
var _arguments = _arguments2;
|
||||
var _arguments = arguments;
|
||||
|
||||
var foo = function () {
|
||||
return _arguments;
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
var arguments = [1, 2, 3];
|
||||
var arr = () => arguments[0];
|
||||
|
||||
expect(arr()).toStrictEqual(1)
|
||||
|
||||
function foo(n) {
|
||||
var f = () => arguments[0] + n; // foo's implicit arguments binding. arguments[0] is n
|
||||
return f();
|
||||
}
|
||||
|
||||
expect(foo(3)).toStrictEqual(6)
|
||||
@ -0,0 +1,10 @@
|
||||
var arguments = [1, 2, 3];
|
||||
var arr = (n) => arguments[0];
|
||||
|
||||
arr(4); // 1
|
||||
|
||||
function foo(n) {
|
||||
var f = () => arguments[0] + n; // foo's implicit arguments binding. arguments[0] is n
|
||||
return f();
|
||||
}
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
{
|
||||
"sourceType": "script",
|
||||
"plugins": ["transform-arrow-functions"]
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
var _arguments = [1, 2, 3];
|
||||
|
||||
var arr = function (n) {
|
||||
return _arguments[0];
|
||||
};
|
||||
|
||||
arr(4); // 1
|
||||
|
||||
function foo(n) {
|
||||
var _arguments2 = arguments;
|
||||
|
||||
var f = function () {
|
||||
return _arguments2[0] + n;
|
||||
}; // foo's implicit arguments binding. arguments[0] is n
|
||||
|
||||
|
||||
return f();
|
||||
}
|
||||
@ -1138,6 +1138,13 @@ export default class Scope {
|
||||
} else {
|
||||
return binding;
|
||||
}
|
||||
} else if (
|
||||
!binding &&
|
||||
name === "arguments" &&
|
||||
scope.path.isFunction() &&
|
||||
!scope.path.isArrowFunctionExpression()
|
||||
) {
|
||||
break;
|
||||
}
|
||||
previousPath = scope.path;
|
||||
} while ((scope = scope.parent));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user