mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-05 16:14:38 +00:00
LibJS: Multiple 'default' clauses in switch statement are a syntax error
This commit is contained in:
committed by
Andreas Kling
parent
57e7b2f8e4
commit
2dbea60fe2
@@ -1519,8 +1519,15 @@ NonnullRefPtr<SwitchStatement> Parser::parse_switch_statement()
|
||||
|
||||
NonnullRefPtrVector<SwitchCase> cases;
|
||||
|
||||
while (match(TokenType::Case) || match(TokenType::Default))
|
||||
auto has_default = false;
|
||||
while (match(TokenType::Case) || match(TokenType::Default)) {
|
||||
if (match(TokenType::Default)) {
|
||||
if (has_default)
|
||||
syntax_error("Multiple 'default' clauses in switch statement");
|
||||
has_default = true;
|
||||
}
|
||||
cases.append(parse_switch_case());
|
||||
}
|
||||
|
||||
consume(TokenType::CurlyClose);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user