diff --git a/trunk_parser/src/parser/mod.rs b/trunk_parser/src/parser/mod.rs index 938d5f0..e6b4547 100644 --- a/trunk_parser/src/parser/mod.rs +++ b/trunk_parser/src/parser/mod.rs @@ -695,7 +695,7 @@ impl Parser { let condition = self.expression(0)?; - expect!(self, TokenKind::Colon, "expected :"); + expect!(self, TokenKind::Colon | TokenKind::SemiColon, "expected :"); let mut body = Block::new(); @@ -714,7 +714,7 @@ impl Parser { TokenKind::Default => { self.next(); - expect!(self, TokenKind::Colon, "expected :"); + expect!(self, TokenKind::Colon | TokenKind::SemiColon, "expected :"); let mut body = Block::new(); @@ -2193,7 +2193,7 @@ mod tests { use super::Parser; use crate::{ ast::{ - Arg, ArrayItem, Constant, DeclareItem, ElseIf, IncludeKind, InfixOp, MethodFlag, + Arg, ArrayItem, Case, Constant, DeclareItem, ElseIf, IncludeKind, InfixOp, MethodFlag, PropertyFlag, }, Catch, Expression, Identifier, Param, Statement, Type, @@ -3484,6 +3484,37 @@ mod tests { ) } + #[test] + fn switch() { + assert_ast( + "