Skip to content

Commit

Permalink
fix(parser): fixed edgy cases
Browse files Browse the repository at this point in the history
  • Loading branch information
KFlash committed Aug 13, 2019
1 parent 43130ac commit a4434ef
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 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.7",
"version": "1.6.8",
"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
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.7';
export const version = '1.6.8';
6 changes: 3 additions & 3 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3871,12 +3871,12 @@ export function parseMemberOrUpdateExpression(
}

if ((parser.token & Token.IsMemberOrCallExpression) === Token.IsMemberOrCallExpression) {
context = (context | Context.DisallowIn) ^ Context.DisallowIn;
context = (context | Context.DisallowIn | Context.InGlobal) ^ (Context.DisallowIn | Context.InGlobal);

switch (parser.token) {
/* Property */
case Token.Period: {
nextToken(parser, context);
nextToken(parser, context | Context.AllowEscapedKeyword);

parser.assignable = AssignmentKind.Assignable;

Expand Down Expand Up @@ -7309,7 +7309,7 @@ export function parseMembeExpressionNoCall(
if (token & Token.IsMemberOrCallExpression) {
/* Property */
if (token === Token.Period) {
nextToken(parser, context);
nextToken(parser, context | Context.AllowEscapedKeyword);

parser.assignable = AssignmentKind.Assignable;

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 @@ -11,6 +11,7 @@ describe('Miscellaneous - Escaped keywords', () => {
'(\\u0069nterface = 1);',
'({ def\\u0061ult: 0 })',
'({ def\\u{61}ult: 0 })',
'foo = {}; foo.def\\u{61}ult = 3;',
'var int\\u0065rface = 1;',
'var { int\\u0065rface } = {};',
'(p\\u0061ckage = 1);',
Expand Down Expand Up @@ -104,6 +105,7 @@ describe('Miscellaneous - Escaped keywords', () => {
['(x === tr\\u0075e);', Context.None],
['var x = tr\\u0075e;', Context.None],
['var tr\\u0075e = 1;', Context.None],
['({ def\\u0061ult })', Context.None],
['var { tr\\u0075e } = {};', Context.None],
['tr\\u0075e = 1;', Context.None],
['(x === f\\u0061lse);', Context.None],
Expand Down

0 comments on commit a4434ef

Please sign in to comment.