Enable ergonomic brand checks (#priv in) by default (#13554)

* Enable ergonomic brand checks by default in `@babel/parser`

* Enable ergonomic brand checks by default in `preset-env`

* Fix error position

* Update Babel 8 tests
This commit is contained in:
Nicolò Ribaudo
2021-08-03 23:02:17 +02:00
committed by GitHub
parent 5f4b58f678
commit a254ea38a4
180 changed files with 281 additions and 61 deletions

View File

@@ -1154,16 +1154,12 @@ export default class ExpressionParser extends LValParser {
// https://tc39.es/proposal-private-fields-in-in
// RelationalExpression [In, Yield, Await]
// [+In] PrivateIdentifier in ShiftExpression[?Yield, ?Await]
const start = this.state.start;
const value = this.state.value;
const { value, start } = this.state;
node = this.parsePrivateName();
if (this.match(tt._in)) {
this.expectPlugin("privateIn");
this.classScope.usePrivateName(value, node.start);
} else if (this.hasPlugin("privateIn")) {
this.raise(this.state.start, Errors.PrivateInExpectedIn, value);
this.classScope.usePrivateName(value, start);
} else {
throw this.unexpected(start);
this.raise(start, Errors.PrivateInExpectedIn, value);
}
return node;
}