Skip to content

Commit af9503a

Browse files
committed
added support for hanging comma
1 parent 7bceb3f commit af9503a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/parser/expr.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,10 @@ module.exports = {
645645
conds.push(this.read_expr());
646646
while (this.token === ",") {
647647
this.next();
648+
if (this.token === this.tok.T_DOUBLE_ARROW) {
649+
this.next();
650+
return conds;
651+
}
648652
conds.push(this.read_expr());
649653
}
650654
}

test/snapshot/match.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe("match", () => {
3434
it("can have hanging comma", () => {
3535
const ast = parser.parseEval(`
3636
$test = match($test) {
37-
true => 'ok',
37+
true, => 'ok',
3838
false => 'Nope!',
3939
};
4040
`);

0 commit comments

Comments
 (0)