Support when after binop

This commit is contained in:
Richard Feldman 2022-07-24 18:20:38 -04:00
parent bbf867c1d1
commit a1a3eff278
No known key found for this signature in database
GPG key ID: 7E4127D1E4241798

View file

@ -189,7 +189,7 @@ fn record_field_access<'a>() -> impl Parser<'a, &'a str, EExpr<'a>> {
/// In some contexts we want to parse the `_` as an expression, so it can then be turned into a
/// pattern later
fn parse_loc_term_or_underscore_or_if<'a>(
fn parse_loc_term_or_underscore_or_conditional<'a>(
min_indent: u32,
options: ExprParseOptions,
arena: &'a Bump,
@ -198,6 +198,10 @@ fn parse_loc_term_or_underscore_or_if<'a>(
one_of!(
loc_expr_in_parens_etc_help(min_indent),
loc!(specialize(EExpr::If, if_expr_help(min_indent, options))),
loc!(specialize(
EExpr::When,
when::expr_help(min_indent, options)
)),
loc!(specialize(EExpr::Str, string_literal_help())),
loc!(specialize(EExpr::SingleQuote, single_quote_literal_help())),
loc!(specialize(EExpr::Number, positive_number_literal_help())),
@ -304,7 +308,9 @@ fn loc_possibly_negative_or_negated_term<'a>(
Expr::UnaryOp(arena.alloc(loc_expr), Loc::at(loc_op.region, UnaryOp::Not))
}
)),
|arena, state| { parse_loc_term_or_underscore_or_if(min_indent, options, arena, state) }
|arena, state| {
parse_loc_term_or_underscore_or_conditional(min_indent, options, arena, state)
}
]
}