Spec Violation: Fix var initializer in for-in loop (#7392)
This commit is contained in:
committed by
Logan Smyth
parent
fc64ab5725
commit
d187c26748
@@ -367,8 +367,19 @@ export default class StatementParser extends ExpressionParser {
|
||||
this.finishNode(init, "VariableDeclaration");
|
||||
|
||||
if (this.match(tt._in) || this.isContextual("of")) {
|
||||
if (init.declarations.length === 1 && !init.declarations[0].init) {
|
||||
return this.parseForIn(node, init, forAwait);
|
||||
if (init.declarations.length === 1) {
|
||||
const declaration = init.declarations[0];
|
||||
const isForInInitializer =
|
||||
varKind === tt._var &&
|
||||
declaration.init &&
|
||||
declaration.id.type != "ObjectPattern" &&
|
||||
declaration.id.type != "ArrayPattern" &&
|
||||
!this.isContextual("of");
|
||||
if (this.state.strict && isForInInitializer) {
|
||||
this.raise(this.state.start, "for-in initializer in strict mode");
|
||||
} else if (isForInInitializer || !declaration.init) {
|
||||
return this.parseForIn(node, init, forAwait);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (forAwait) {
|
||||
|
||||
Reference in New Issue
Block a user