Add back parser restrictions

This commit is contained in:
greg 2019-10-11 09:11:14 -07:00
parent 3cf3fce72d
commit 44d1f4692f
2 changed files with 4 additions and 1 deletions

View File

@ -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"
}

View File

@ -813,12 +813,15 @@ impl Parser {
#[recursive_descent_method]
fn if_expr(&mut self) -> ParseResult<Expression> {
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 }))
}