Add private-property-in-object support (#11372)
https://github.com/tc39/proposal-private-fields-in-in Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com> Co-Authored-By: Huáng Jùnliàng <jlhwung@gmail.com>
This commit is contained in:
committed by
Nicolò Ribaudo
parent
2d27cf819e
commit
7459038db8
@@ -27,6 +27,7 @@ import {
|
||||
isReservedWord,
|
||||
isStrictReservedWord,
|
||||
isStrictBindReservedWord,
|
||||
isIdentifierStart,
|
||||
} from "../util/identifier";
|
||||
import type { Pos, Position } from "../util/location";
|
||||
import * as charCodes from "charcodes";
|
||||
@@ -1148,6 +1149,26 @@ export default class ExpressionParser extends LValParser {
|
||||
this.registerTopicReference();
|
||||
return this.finishNode(node, "PipelinePrimaryTopicReference");
|
||||
}
|
||||
|
||||
const nextCh = this.input.codePointAt(this.state.end);
|
||||
if (isIdentifierStart(nextCh) || nextCh === charCodes.backslash) {
|
||||
const start = this.state.start;
|
||||
// $FlowIgnore It'll either parse a PrivateName or throw.
|
||||
node = (this.parseMaybePrivateName(true): N.PrivateName);
|
||||
if (this.match(tt._in)) {
|
||||
this.expectPlugin("privateIn");
|
||||
this.classScope.usePrivateName(node.id.name, node.start);
|
||||
} else if (this.hasPlugin("privateIn")) {
|
||||
this.raise(
|
||||
this.state.start,
|
||||
Errors.PrivateInExpectedIn,
|
||||
node.id.name,
|
||||
);
|
||||
} else {
|
||||
throw this.unexpected(start);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
}
|
||||
// fall through
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user