fix: push new token context when braceHashL is seen (#11941)

* fix: push new token context when braceHashL is seen

* Update packages/babel-parser/src/tokenizer/context.js
This commit is contained in:
Huáng Jùnliàng
2020-08-11 09:55:13 -04:00
committed by GitHub
parent a5bc48661b
commit 3995160fc7
10 changed files with 221 additions and 0 deletions

View File

@@ -31,6 +31,7 @@ export const types: {
} = {
braceStatement: new TokContext("{", false),
braceExpression: new TokContext("{", true),
recordExpression: new TokContext("#{", true),
templateQuasi: new TokContext("${", false),
parenStatement: new TokContext("(", false),
parenExpression: new TokContext("(", true),
@@ -140,3 +141,9 @@ tt.backQuote.updateContext = function () {
tt.star.updateContext = function () {
this.state.exprAllowed = false;
};
// we don't need to update context for tt.braceBarL because we do not pop context for tt.braceBarR
tt.braceHashL.updateContext = function () {
this.state.context.push(types.recordExpression);
this.state.exprAllowed = true; /* tt.braceHashL.beforeExpr */
};