Skip to content

Commit c3cff35

Browse files
crisbetoatscott
authored andcommitted
fix(compiler): handle trailing comma in object literal (#49535)
Fixes that the compiler wasn't parsing an object literal with a trailing comma correctly. Fixes #49534. PR Close #49535
1 parent a844435 commit c3cff35

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

packages/compiler/src/expression_parser/parser.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,8 @@ export class _ParseAST {
949949
values.push(new PropertyRead(
950950
span, sourceSpan, sourceSpan, new ImplicitReceiver(span, sourceSpan), key));
951951
}
952-
} while (this.consumeOptionalCharacter(chars.$COMMA));
952+
} while (this.consumeOptionalCharacter(chars.$COMMA) &&
953+
!this.next.isCharacter(chars.$RBRACE));
953954
this.rbracesExpected--;
954955
this.expectCharacter(chars.$RBRACE);
955956
}

packages/compiler/test/expression_parser/parser_spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ describe('parser', () => {
116116
checkAction('{}');
117117
checkAction('{a: 1, "b": 2}[2]');
118118
checkAction('{}["a"]');
119+
checkAction('{a: 1, b: 2,}', '{a: 1, b: 2}');
119120
});
120121

121122
it('should only allow identifier, string, or keyword as map key', () => {

0 commit comments

Comments
 (0)