diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index c715cdf23e1c..48700da44ab5 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -2110,7 +2110,8 @@ export default class ExpressionParser extends LValParser { this.state.inParameters = false; if (isExpression) { - node.body = this.parseMaybeAssignAllowIn(); + // https://tc39.es/ecma262/#prod-ExpressionBody + node.body = this.parseMaybeAssign(); this.checkParams(node, false, allowExpression, false); } else { const oldStrict = this.state.strict; diff --git a/packages/babel-parser/test/fixtures/es2015/arrow-functions/no-for-in-init/input.js b/packages/babel-parser/test/fixtures/es2015/arrow-functions/no-for-in-init/input.js new file mode 100644 index 000000000000..dbd82197960c --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/arrow-functions/no-for-in-init/input.js @@ -0,0 +1 @@ +for (() => x in y;;); diff --git a/packages/babel-parser/test/fixtures/es2015/arrow-functions/no-for-in-init/options.json b/packages/babel-parser/test/fixtures/es2015/arrow-functions/no-for-in-init/options.json new file mode 100644 index 000000000000..fefc8a397fe9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/arrow-functions/no-for-in-init/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected \")\" (1:17)" +} \ No newline at end of file