diff --git a/schala-lang/language/src/eval/test.rs b/schala-lang/language/src/eval/test.rs index 6e03711..526ca75 100644 --- a/schala-lang/language/src/eval/test.rs +++ b/schala-lang/language/src/eval/test.rs @@ -133,7 +133,7 @@ test_in_fresh_env!(source, "\"x\""); fn boolean_pattern() { let source = r#" let a = true -if a { +if a { is true then "x", is false then "y" } diff --git a/schala-lang/language/src/parsing.rs b/schala-lang/language/src/parsing.rs index 50f2ef4..0c1a74f 100644 --- a/schala-lang/language/src/parsing.rs +++ b/schala-lang/language/src/parsing.rs @@ -813,12 +813,15 @@ impl Parser { #[recursive_descent_method] fn if_expr(&mut self) -> ParseResult { expect!(self, Keyword(Kw::If)); + let old_struct_value = self.restrictions.no_struct_literal; + self.restrictions.no_struct_literal = true; let discriminator = if let LCurlyBrace = self.token_handler.peek_kind() { None } else { Some(Box::new(self.expression()?)) }; let body = Box::new(self.if_expr_body()?); + self.restrictions.no_struct_literal = old_struct_value; Ok(Expression::new(self.id_store.fresh(), ExpressionKind::IfExpression { discriminator, body })) }