Skip to content

Commit

Permalink
fix(parser): fixed computed property names - added missing "parseMemb…
Browse files Browse the repository at this point in the history
…erOrUpdateExpression"
  • Loading branch information
KFlash committed May 14, 2019
1 parent 1a887fd commit 01add5d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3996,6 +3996,8 @@ export function parseObjectLiteralOrPattern(
? parseArrayExpressionOrPattern(parser, context, /* skipInitializer */ 0, type)
: parseObjectLiteralOrPattern(parser, context, /* skipInitializer */ 0, type);

value = parseMemberOrUpdateExpression(parser, context, value, /* isNewExpression */ 0);

destructible = parser.destructible;

parser.assignable =
Expand All @@ -4010,14 +4012,12 @@ export function parseObjectLiteralOrPattern(
? DestructuringKind.Assignable
: DestructuringKind.NotDestructible) | parser.assignable;
}
} else {
if (parser.token !== Token.LeftParen) {
report(parser, Errors.InvalidComputedPropName);
}

} else if (parser.token === Token.LeftParen) {
state |= PropertyKind.Method;
value = parseMethodDefinition(parser, context, state);
destructible |= parser.assignable | DestructuringKind.NotDestructible;
destructible = DestructuringKind.NotDestructible;
} else {
report(parser, Errors.InvalidComputedPropName);
}
} else if (parser.token === Token.Multiply) {
consume(parser, context | Context.AllowRegExp, Token.Multiply);
Expand Down
41 changes: 41 additions & 0 deletions test/parser/expressions/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11158,6 +11158,47 @@ describe('Expressions - Object', () => {
]
}
],
[
'({ [a]: {} [a] })',
Context.None,
{
type: 'Program',
sourceType: 'script',
body: [
{
type: 'ExpressionStatement',
expression: {
type: 'ObjectExpression',
properties: [
{
type: 'Property',
key: {
type: 'Identifier',
name: 'a'
},
value: {
type: 'MemberExpression',
object: {
type: 'ObjectExpression',
properties: []
},
computed: true,
property: {
type: 'Identifier',
name: 'a'
}
},
kind: 'init',
computed: true,
method: false,
shorthand: false
}
]
}
}
]
}
],
[
'x = {15:b}',
Context.None,
Expand Down

0 comments on commit 01add5d

Please sign in to comment.