Skip to content

Commit 4ab4179

Browse files
committed
Enforce at least one case
1 parent 837a358 commit 4ab4179

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

src/plugins/lightscript.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,10 @@ pp.parseMatch = function (node, isExpression) {
587587
node.cases.push(matchCase);
588588
}
589589

590+
if (!node.cases.length) {
591+
this.unexpected(null, tt.bitwiseOR);
592+
}
593+
590594
return this.finishNode(node, isExpression ? "MatchExpression" : "MatchStatement");
591595
};
592596

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
match x:
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"throws": "Unexpected token, expected | (1:8)"
3+
}

0 commit comments

Comments
 (0)