Skip to content

Commit f22fffd

Browse files
committed
Evaluate arguments in function's scope
1 parent 55ce143 commit f22fffd

File tree

1 file changed

+27
-23
lines changed

1 file changed

+27
-23
lines changed

lib/Parser.js

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,23 +1030,28 @@ class Parser extends Tapable {
10301030
}
10311031

10321032
walkForInStatement(statement) {
1033-
if (statement.left.type === "VariableDeclaration")
1033+
if (statement.left.type === "VariableDeclaration") {
10341034
this.walkVariableDeclaration(statement.left);
1035-
else this.walkPattern(statement.left);
1035+
} else {
1036+
this.walkPattern(statement.left);
1037+
}
10361038
this.walkExpression(statement.right);
10371039
this.walkStatement(statement.body);
10381040
}
10391041

10401042
prewalkForOfStatement(statement) {
1041-
if (statement.left.type === "VariableDeclaration")
1043+
if (statement.left.type === "VariableDeclaration") {
10421044
this.prewalkVariableDeclaration(statement.left);
1045+
}
10431046
this.prewalkStatement(statement.body);
10441047
}
10451048

10461049
walkForOfStatement(statement) {
1047-
if (statement.left.type === "VariableDeclaration")
1050+
if (statement.left.type === "VariableDeclaration") {
10481051
this.walkVariableDeclaration(statement.left);
1049-
else this.walkPattern(statement.left);
1052+
} else {
1053+
this.walkPattern(statement.left);
1054+
}
10501055
this.walkExpression(statement.right);
10511056
this.walkStatement(statement.body);
10521057
}
@@ -1062,8 +1067,10 @@ class Parser extends Tapable {
10621067
walkFunctionDeclaration(statement) {
10631068
const wasTopLevel = this.scope.topLevelScope;
10641069
this.scope.topLevelScope = false;
1065-
for (const param of statement.params) this.walkPattern(param);
10661070
this.inScope(statement.params, () => {
1071+
for (const param of statement.params) {
1072+
this.walkPattern(param);
1073+
}
10671074
if (statement.body.type === "BlockStatement") {
10681075
this.detectStrictMode(statement.body.body);
10691076
this.prewalkStatement(statement.body);
@@ -1355,13 +1362,10 @@ class Parser extends Tapable {
13551362
}
13561363

13571364
walkExpressions(expressions) {
1358-
for (
1359-
let expressionsIndex = 0, len = expressions.length;
1360-
expressionsIndex < len;
1361-
expressionsIndex++
1362-
) {
1363-
const expression = expressions[expressionsIndex];
1364-
if (expression) this.walkExpression(expression);
1365+
for (const expression of expressions) {
1366+
if (expression) {
1367+
this.walkExpression(expression);
1368+
}
13651369
}
13661370
}
13671371

@@ -1469,8 +1473,10 @@ class Parser extends Tapable {
14691473
walkFunctionExpression(expression) {
14701474
const wasTopLevel = this.scope.topLevelScope;
14711475
this.scope.topLevelScope = false;
1472-
for (const param of expression.params) this.walkPattern(param);
14731476
this.inScope(expression.params, () => {
1477+
for (const param of expression.params) {
1478+
this.walkPattern(param);
1479+
}
14741480
if (expression.body.type === "BlockStatement") {
14751481
this.detectStrictMode(expression.body.body);
14761482
this.prewalkStatement(expression.body);
@@ -1483,8 +1489,10 @@ class Parser extends Tapable {
14831489
}
14841490

14851491
walkArrowFunctionExpression(expression) {
1486-
for (const param of expression.params) this.walkPattern(param);
14871492
this.inScope(expression.params, () => {
1493+
for (const param of expression.params) {
1494+
this.walkPattern(param);
1495+
}
14881496
if (expression.body.type === "BlockStatement") {
14891497
this.detectStrictMode(expression.body.body);
14901498
this.prewalkStatement(expression.body);
@@ -1640,7 +1648,9 @@ class Parser extends Tapable {
16401648
if (functionExpression.body.type === "BlockStatement") {
16411649
this.prewalkStatement(functionExpression.body);
16421650
this.walkStatement(functionExpression.body);
1643-
} else this.walkExpression(functionExpression.body);
1651+
} else {
1652+
this.walkExpression(functionExpression.body);
1653+
}
16441654
});
16451655
this.scope.topLevelScope = wasTopLevel;
16461656
}
@@ -1743,13 +1753,7 @@ class Parser extends Tapable {
17431753

17441754
this.scope.renames.set("this", null);
17451755

1746-
for (
1747-
let paramIndex = 0, len = params.length;
1748-
paramIndex < len;
1749-
paramIndex++
1750-
) {
1751-
const param = params[paramIndex];
1752-
1756+
for (const param of params) {
17531757
if (typeof param !== "string") {
17541758
this.enterPattern(param, param => {
17551759
this.scope.renames.set(param, null);

0 commit comments

Comments
 (0)