Add back parser restrictions
This commit is contained in:
parent
3cf3fce72d
commit
44d1f4692f
@ -133,7 +133,7 @@ test_in_fresh_env!(source, "\"x\"");
|
|||||||
fn boolean_pattern() {
|
fn boolean_pattern() {
|
||||||
let source = r#"
|
let source = r#"
|
||||||
let a = true
|
let a = true
|
||||||
if a {
|
if a {
|
||||||
is true then "x",
|
is true then "x",
|
||||||
is false then "y"
|
is false then "y"
|
||||||
}
|
}
|
||||||
|
@ -813,12 +813,15 @@ impl Parser {
|
|||||||
#[recursive_descent_method]
|
#[recursive_descent_method]
|
||||||
fn if_expr(&mut self) -> ParseResult<Expression> {
|
fn if_expr(&mut self) -> ParseResult<Expression> {
|
||||||
expect!(self, Keyword(Kw::If));
|
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() {
|
let discriminator = if let LCurlyBrace = self.token_handler.peek_kind() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(Box::new(self.expression()?))
|
Some(Box::new(self.expression()?))
|
||||||
};
|
};
|
||||||
let body = Box::new(self.if_expr_body()?);
|
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 }))
|
Ok(Expression::new(self.id_store.fresh(), ExpressionKind::IfExpression { discriminator, body }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user