JsRoot {
interpreter_token: missing (optional),
directives: [],
statements: [
JsSwitchStatement {
switch_token: SWITCH_KW@0..7 "switch" [] [Whitespace(" ")],
l_paren_token: L_PAREN@7..8 "(" [] [],
discriminant: JsReferenceIdentifierExpression {
name_token: IDENT@8..11 "foo" [] [],
},
r_paren_token: R_PAREN@11..13 ")" [] [Whitespace(" ")],
l_curly_token: L_CURLY@13..14 "{" [] [],
cases: [
JsDefaultClause {
default_token: DEFAULT_KW@14..23 "default" [Whitespace("\n\t")] [],
colon_token: COLON@23..25 ":" [] [Whitespace(" ")],
consequent: [
JsBlockStatement {
l_curly_token: L_CURLY@25..26 "{" [] [],
statements: [],
r_curly_token: R_CURLY@26..27 "}" [] [],
},
],
},
JsDefaultClause {
default_token: DEFAULT_KW@27..36 "default" [Whitespace("\n\t")] [],
colon_token: COLON@36..38 ":" [] [Whitespace(" ")],
consequent: [
JsBlockStatement {
l_curly_token: L_CURLY@38..39 "{" [] [],
statements: [],
r_curly_token: R_CURLY@39..40 "}" [] [],
},
],
},
],
r_curly_token: R_CURLY@40..42 "}" [Whitespace("\n")] [],
},
],
}
0: JS_ROOT@0..43
0: (empty)
1: LIST@0..0
2: LIST@0..42
0: JS_SWITCH_STATEMENT@0..42
0: SWITCH_KW@0..7 "switch" [] [Whitespace(" ")]
1: L_PAREN@7..8 "(" [] []
2: JS_REFERENCE_IDENTIFIER_EXPRESSION@8..11
0: IDENT@8..11 "foo" [] []
3: R_PAREN@11..13 ")" [] [Whitespace(" ")]
4: L_CURLY@13..14 "{" [] []
5: LIST@14..40
0: JS_DEFAULT_CLAUSE@14..27
0: DEFAULT_KW@14..23 "default" [Whitespace("\n\t")] []
1: COLON@23..25 ":" [] [Whitespace(" ")]
2: LIST@25..27
0: JS_BLOCK_STATEMENT@25..27
0: L_CURLY@25..26 "{" [] []
1: LIST@26..26
2: R_CURLY@26..27 "}" [] []
1: JS_DEFAULT_CLAUSE@27..40
0: DEFAULT_KW@27..36 "default" [Whitespace("\n\t")] []
1: COLON@36..38 ":" [] [Whitespace(" ")]
2: LIST@38..40
0: JS_BLOCK_STATEMENT@38..40
0: L_CURLY@38..39 "{" [] []
1: LIST@39..39
2: R_CURLY@39..40 "}" [] []
6: R_CURLY@40..42 "}" [Whitespace("\n")] []
3: EOF@42..43 "" [Whitespace("\n")] []
--
error[SyntaxError]: Multiple default clauses inside of a switch statement are not allowed
┌─ switch_stmt_double_default.js:3:2
│
2 │ default: {}
│ ---------- the first default clause is defined here
3 │ default: {}
│ ^^^^^^^^^^ a second clause here is not allowed
--
switch (foo) {
default: {}
default: {}
}