Skip to content

Commit

Permalink
fix(parser): fixed a few edgy cases
Browse files Browse the repository at this point in the history
  • Loading branch information
KFlash committed Aug 13, 2019
1 parent 90c139c commit 43130ac
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "meriyah",
"version": "1.6.6",
"version": "1.6.7",
"description": "A 100% compliant, self-hosted javascript parser with high focus on both performance and stability",
"main": "dist/meriyah.umd.js",
"module": "dist/meriyah.esm.js",
Expand Down
7 changes: 6 additions & 1 deletion src/lexer/identifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ export function scanIdentifierSlowCase(
? Token.EscapedFutureReserved
: Token.EscapedReserved;
}

if (
context & Context.AllowEscapedKeyword &&
(context & Context.InGlobal) === 0 &&
(token & Token.Reserved) === Token.Reserved
)
return token;
if (token === Token.YieldKeyword) {
return context & Context.AllowEscapedKeyword
? Token.AnyIdentifier
Expand Down
2 changes: 1 addition & 1 deletion src/meriyah.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ export function parse(source: string, options?: Options): ESTree.Program {
export { Options, ESTree };

// Export current version
export const version = '1.6.6';
export const version = '1.6.7';
2 changes: 1 addition & 1 deletion src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6698,7 +6698,7 @@ export function parseParenthesizedExpression(

const scope = context & Context.OptionsLexical ? addChildScope(createScope(), ScopeKind.ArrowParams) : void 0;

context = (context | Context.DisallowIn) ^ Context.DisallowIn;
context = (context | Context.DisallowIn | Context.InGlobal) ^ (Context.InGlobal | Context.DisallowIn);

if (consumeOpt(parser, context, Token.RightParen)) {
// Not valid expression syntax, but this is valid in an arrow function
Expand Down
2 changes: 2 additions & 0 deletions test/parser/miscellaneous/escaped-keyword.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ describe('Miscellaneous - Escaped keywords', () => {
'var impl\\u0065ments = 1;',
'var { impl\\u0065ments } = {};',
'(\\u0069nterface = 1);',
'({ def\\u0061ult: 0 })',
'({ def\\u{61}ult: 0 })',
'var int\\u0065rface = 1;',
'var { int\\u0065rface } = {};',
'(p\\u0061ckage = 1);',
Expand Down

0 comments on commit 43130ac

Please sign in to comment.