mirror of
https://github.com/roc-lang/roc.git
synced 2024-10-04 14:17:28 +03:00
Merge pull request #6862 from JRI98/fix_6215
Fix handling of spaces after for `as`
This commit is contained in:
commit
1d1b96abb9
@ -63,9 +63,14 @@ pub fn loc_pattern_help<'a>() -> impl Parser<'a, Loc<Pattern<'a>>, EPattern<'a>>
|
||||
},
|
||||
Ok((_, pattern_as, state)) => {
|
||||
let region = Region::span_across(&pattern.region, &pattern_as.identifier.region);
|
||||
let pattern = arena
|
||||
.alloc(pattern.value)
|
||||
.with_spaces_after(pattern_spaces, pattern.region);
|
||||
|
||||
let mut pattern = pattern;
|
||||
if !pattern_spaces.is_empty() {
|
||||
pattern = arena
|
||||
.alloc(pattern.value)
|
||||
.with_spaces_after(pattern_spaces, pattern.region)
|
||||
}
|
||||
|
||||
let as_pattern = Pattern::As(arena.alloc(pattern), pattern_as);
|
||||
|
||||
Ok((MadeProgress, Loc::at(region, as_pattern), state))
|
||||
|
@ -7,11 +7,8 @@ When(
|
||||
patterns: [
|
||||
@14-20 SpaceBefore(
|
||||
As(
|
||||
@14-15 SpaceAfter(
|
||||
Underscore(
|
||||
"",
|
||||
),
|
||||
[],
|
||||
@14-15 Underscore(
|
||||
"",
|
||||
),
|
||||
PatternAs {
|
||||
spaces_before: [],
|
||||
|
@ -6113,6 +6113,31 @@ mod test_fmt {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_6215() {
|
||||
expr_formats_to(
|
||||
indoc!(
|
||||
r"
|
||||
when list is
|
||||
[first as last]
|
||||
| [first, last] ->
|
||||
first
|
||||
_->Not
|
||||
"
|
||||
),
|
||||
indoc!(
|
||||
r"
|
||||
when list is
|
||||
[first as last]
|
||||
| [first, last] ->
|
||||
first
|
||||
|
||||
_ -> Not
|
||||
"
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// this is a parse error atm
|
||||
// #[test]
|
||||
// fn multiline_apply() {
|
||||
|
Loading…
Reference in New Issue
Block a user