Add ??= to Logical Assignment Operators (#7623)
`??=` is being merged into the Logical Assignment Operator proposal, and the overall proposal will wait until nullish coalescing is finalized.
This commit is contained in:
@@ -299,10 +299,6 @@ export default class ExpressionParser extends LValParser {
|
||||
this.state.potentialArrowAt = startPos;
|
||||
}
|
||||
|
||||
if (node.operator === "??") {
|
||||
this.expectPlugin("nullishCoalescingOperator");
|
||||
}
|
||||
|
||||
node.right = this.parseExprOp(
|
||||
this.parseMaybeUnary(),
|
||||
startPos,
|
||||
|
||||
@@ -607,8 +607,16 @@ export default class Tokenizer extends LocationParser {
|
||||
const next = this.input.charCodeAt(this.state.pos + 1);
|
||||
const next2 = this.input.charCodeAt(this.state.pos + 2);
|
||||
if (next === charCodes.questionMark) {
|
||||
// '??'
|
||||
this.finishOp(tt.nullishCoalescing, 2);
|
||||
this.expectPlugin("nullishCoalescingOperator");
|
||||
|
||||
if (next2 === charCodes.equalsTo) {
|
||||
// '??='
|
||||
this.expectPlugin("logicalAssignment");
|
||||
this.finishOp(tt.assign, 3);
|
||||
} else {
|
||||
// '??'
|
||||
this.finishOp(tt.nullishCoalescing, 2);
|
||||
}
|
||||
} else if (
|
||||
next === charCodes.dot &&
|
||||
!(next2 >= charCodes.digit0 && next2 <= charCodes.digit9)
|
||||
|
||||
Reference in New Issue
Block a user