allow arrow to be an expr terminator in when guards

This commit is contained in:
Joshua Warner 2025-01-10 19:49:37 -08:00
parent 13a70c060d
commit 05033ac40b
No known key found for this signature in database
GPG key ID: 89AD497003F93FDD
5 changed files with 65 additions and 0 deletions

View file

@ -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()),