Skip to content

Commit

Permalink
fix(parser): ~ (0x7e) is valid stop for Identifier or Keyword
Browse files Browse the repository at this point in the history
closes #226
  • Loading branch information
3cp committed Oct 1, 2022
1 parent 703aa91 commit d702ebd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/lexer/identifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function scanIdentifier(parser: ParserState, context: Context, isValidAsK
while (isIdPart[advanceChar(parser)]) {}
parser.tokenValue = parser.source.slice(parser.tokenPos, parser.index);

return parser.currentChar !== Chars.Backslash && parser.currentChar < 0x7e
return parser.currentChar !== Chars.Backslash && parser.currentChar <= 0x7e
? descKeywordTable[parser.tokenValue] || Token.Identifier
: scanIdentifierSlowCase(parser, context, 0, isValidAsKeyword);
}
Expand Down
5 changes: 3 additions & 2 deletions test/parser/statements/for-of.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,9 @@ describe('Statements - For of', () => {
'for (function(){ }[x in y] of x);',
'for (function(){ if (a in b); }.prop of x);',
'for (function(){ a in b; }.prop of x);',

`for (var { cover = (function () {}), a = (0, function() {}) } of [{}]) {}`
`for (var { cover = (function () {}), a = (0, function() {}) } of [{}]) {}`,
'for(x of ~y);',
'for(x of~y);'
]) {
it(`${arg}`, () => {
t.doesNotThrow(() => {
Expand Down

0 comments on commit d702ebd

Please sign in to comment.