Skip to content

Commit

Permalink
fix(parser): Fixed a bunch of edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
KFlash committed May 16, 2019
1 parent 024e459 commit d7e08fe
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3916,11 +3916,9 @@ export function parseObjectLiteralOrPattern(
}
} else {
value = parseMemberOrUpdateExpression(parser, context, value, /* isNewExpression */ 0);
if (parser.assignable & AssignmentKind.Assignable) {
destructible = 0;
} else {
destructible |= DestructuringKind.NotDestructible;
}

destructible =
parser.assignable & AssignmentKind.Assignable ? 0 : (destructible = DestructuringKind.NotDestructible);

const { token } = parser;

Expand All @@ -3930,9 +3928,7 @@ export function parseObjectLiteralOrPattern(
(context | Context.DisallowInContext) ^ Context.DisallowInContext,
value
);
if (token !== Token.Assign) {
destructible |= DestructuringKind.NotDestructible;
}
if (token !== Token.Assign) destructible |= DestructuringKind.NotDestructible;
}
}
}
Expand Down Expand Up @@ -4039,9 +4035,9 @@ export function parseObjectLiteralOrPattern(
if (parser.assignable & AssignmentKind.NotAssignable) destructible |= DestructuringKind.NotDestructible;
} else {
value = parseMemberOrUpdateExpression(parser, context, value, /* isNewExpression */ 0);
if (parser.assignable & AssignmentKind.Assignable) {
destructible = 0;
}

destructible =
parser.assignable & AssignmentKind.Assignable ? 0 : (destructible = DestructuringKind.NotDestructible);

const { token } = parser;

Expand All @@ -4051,6 +4047,8 @@ export function parseObjectLiteralOrPattern(
(context | Context.DisallowInContext) ^ Context.DisallowInContext,
value
);

if (token !== Token.Assign) destructible |= DestructuringKind.NotDestructible;
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions test/parser/miscellaneous/pass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8034,6 +8034,19 @@ if (a !== "z" || typeof b !== "undefined")
'async function f61(a = () => { "use strict"; return eval("x") }) { var x; return a(); }',
'() => f1(4, 5);',
'var f3 = (...let) => let + 42;',
'while ({["a"]: 2e308.b = function* u() {}} = 8381.11);',
'({ [x]: (x) = "bar" })',
'({ [x]: (x) })',
'({ x: (x) })',
'({ x: (x) })',
'({ x: (x) })',
'({ x: x / y })',
'({ [x]: x / y })',
'({ x: 1 / 2 })',
'({ [x]: 1 / 2 })',
'({ [x = y]: 1 / 2 })',
'({ [x]: (1 / 2)()})',
'({ x: (1 / 2)()})',
'function a(x, ...eval){return eval + x;}',
'function b(x, ...let){return let + x;}',
'function c(x, ...yield){return yield + x;}',
Expand Down

0 comments on commit d7e08fe

Please sign in to comment.