mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 12:18:19 +00:00
allow arrow to be an expr terminator in when guards
This commit is contained in:
parent
13a70c060d
commit
05033ac40b
5 changed files with 65 additions and 0 deletions
|
@ -2998,6 +2998,13 @@ fn parse_stmt_seq<'a, E: SpaceProblem + 'a>(
|
|||
break;
|
||||
}
|
||||
|
||||
// If this expr might be followed by an arrow (e.g. in a when branch guard),
|
||||
// then we also need to treat that as a terminator.
|
||||
if !check_for_arrow.0 && new_state.bytes().starts_with(b"->") {
|
||||
state = state_before_space;
|
||||
break;
|
||||
}
|
||||
|
||||
return Err((
|
||||
MadeProgress,
|
||||
wrap_error(arena.alloc(EExpr::BadExprEnd(state.pos())), state.pos()),
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
when
|
||||
f
|
||||
is
|
||||
s if \t ->
|
||||
"""
|
||||
""" -> e
|
|
@ -0,0 +1,48 @@
|
|||
@0-27 SpaceAfter(
|
||||
When(
|
||||
@5-6 SpaceAfter(
|
||||
Var {
|
||||
module_name: "",
|
||||
ident: "f",
|
||||
},
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
[
|
||||
WhenBranch {
|
||||
patterns: [
|
||||
@10-11 SpaceBefore(
|
||||
Identifier {
|
||||
ident: "s",
|
||||
},
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
],
|
||||
value: @26-27 Var {
|
||||
module_name: "",
|
||||
ident: "e",
|
||||
},
|
||||
guard: Some(
|
||||
@14-24 Closure(
|
||||
[
|
||||
@15-16 Identifier {
|
||||
ident: "t",
|
||||
},
|
||||
],
|
||||
@18-24 Str(
|
||||
Block(
|
||||
[],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
},
|
||||
],
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
)
|
|
@ -0,0 +1,3 @@
|
|||
when f
|
||||
is
|
||||
s if\t->""""""->e
|
|
@ -522,6 +522,7 @@ mod test_snapshots {
|
|||
pass/multiline_str_and_str_in_alias.expr,
|
||||
pass/multiline_str_apply_in_parens_pat.expr,
|
||||
pass/multiline_str_crazyness.expr,
|
||||
pass/multiline_str_in_closure_in_when_guard_wtf.expr,
|
||||
pass/multiline_str_in_pat.expr,
|
||||
pass/multiline_str_interpolation_records.expr,
|
||||
pass/multiline_str_opt_field.expr,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue