@@ -2121,7 +2121,7 @@ impl Parser {
2121
2121
let _ = lexer. next ( ) ;
2122
2122
this. pop_rule_span ( lexer) ;
2123
2123
}
2124
- ( Token :: Paren ( '{' ) | Token :: Attribute , _) => {
2124
+ ( token , _) if is_start_of_compound_statement ( token ) => {
2125
2125
let ( inner, span) = this. block ( lexer, ctx, brace_nesting_level) ?;
2126
2126
block. stmts . push ( ast:: Statement {
2127
2127
kind : ast:: StatementKind :: Block ( inner) ,
@@ -2287,11 +2287,14 @@ impl Parser {
2287
2287
let value = loop {
2288
2288
let value = this. switch_value ( lexer, ctx) ?;
2289
2289
if lexer. skip ( Token :: Separator ( ',' ) ) {
2290
- if lexer. skip ( Token :: Separator ( ':' ) ) {
2290
+ // list of values ends with ':' or a compound statement
2291
+ let next_token = lexer. peek ( ) . 0 ;
2292
+ if next_token == Token :: Separator ( ':' )
2293
+ || is_start_of_compound_statement ( next_token)
2294
+ {
2291
2295
break value;
2292
2296
}
2293
2297
} else {
2294
- lexer. skip ( Token :: Separator ( ':' ) ) ;
2295
2298
break value;
2296
2299
}
2297
2300
cases. push ( ast:: SwitchCase {
@@ -2301,6 +2304,8 @@ impl Parser {
2301
2304
} ) ;
2302
2305
} ;
2303
2306
2307
+ lexer. skip ( Token :: Separator ( ':' ) ) ;
2308
+
2304
2309
let body = this. block ( lexer, ctx, brace_nesting_level) ?. 0 ;
2305
2310
2306
2311
cases. push ( ast:: SwitchCase {
@@ -3244,3 +3249,7 @@ impl Parser {
3244
3249
} )
3245
3250
}
3246
3251
}
3252
+
3253
+ const fn is_start_of_compound_statement < ' a > ( token : Token < ' a > ) -> bool {
3254
+ matches ! ( token, Token :: Attribute | Token :: Paren ( '{' ) )
3255
+ }
0 commit comments