From 44d1f4692f89dfd5ac86bc12c0982771dc0cd729 Mon Sep 17 00:00:00 2001 From: greg Date: Fri, 11 Oct 2019 09:11:14 -0700 Subject: [PATCH] Add back parser restrictions --- schala-lang/language/src/eval/test.rs | 2 +- schala-lang/language/src/parsing.rs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) 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 })) }