Skip to content

Commit

Permalink
fix(parser): all identifiers can be start of an expression
Browse files Browse the repository at this point in the history
closes #342
  • Loading branch information
3cp committed Oct 1, 2024
1 parent e38466b commit 7f800c5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export const enum Token {

/* Contextual keywords */
AsKeyword = 108 | Contextual | IsExpressionStart,
AsyncKeyword = 109 | Contextual | IsIdentifier | IsExpressionStart,
AsyncKeyword = 109 | Contextual | IsExpressionStart | IsIdentifier,
AwaitKeyword = 110 | Contextual | IsExpressionStart | IsIdentifier, // await is only reserved word in async functions or modules
ConstructorKeyword = 111 | Contextual,
GetKeyword = 112 | Contextual,
Expand All @@ -175,7 +175,7 @@ export const enum Token {

EscapedReserved = 120 | IsEscaped,
EscapedFutureReserved = 121 | IsEscaped,
AnyIdentifier = 122 | IsIdentifier,
AnyIdentifier = 122 | IsExpressionStart | IsIdentifier,

PrivateIdentifier = 123,
BigIntLiteral = 124 | IsExpressionStart | IsStringOrNumber,
Expand All @@ -189,8 +189,8 @@ export const enum Token {
PrivateField = 130,
Template = 131,
Decorator = 132,
Target = 133 | IsIdentifier,
Meta = 134 | IsIdentifier,
Target = 133 | IsExpressionStart | IsIdentifier,
Meta = 134 | IsExpressionStart | IsIdentifier,
LineFeed = 135,
EscapeStart = 136,

Expand Down
4 changes: 3 additions & 1 deletion test/parser/expressions/await.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ describe('Expressions - Await', () => {
'({ async* f(a, b = 2) { yield 1; } })',
'({ async* f(a, b) { yield 1; } })',
'({ async* f(a) { yield 1; } })',
'(x = class A {[await](){}; "x"(){}}) => {}'
'(x = class A {[await](){}; "x"(){}}) => {}',
'async function a() { await target }',
'async function a() { await meta }'
]) {
it(`${arg}`, () => {
t.doesNotThrow(() => {
Expand Down

0 comments on commit 7f800c5

Please sign in to comment.