Fix multi-backpassing in top-level defs

Fixes #4821
This commit is contained in:
Joshua Warner 2023-01-15 10:38:14 -08:00
parent 545e6bc989
commit 3b51d7cd13
No known key found for this signature in database
GPG Key ID: 89AD497003F93FDD
5 changed files with 77 additions and 3 deletions

View File

@ -924,7 +924,7 @@ macro_rules! join_alias_to_body {
}
fn parse_defs_end<'a>(
_options: ExprParseOptions,
options: ExprParseOptions,
min_indent: u32,
mut defs: Defs<'a>,
arena: &'a Bump,
@ -935,7 +935,7 @@ fn parse_defs_end<'a>(
loop {
let state = global_state;
global_state = match parse_single_def(_options, min_indent, arena, state) {
global_state = match parse_single_def(options, min_indent, arena, state) {
Ok((_, Some(single_def), next_state)) => {
let region = single_def.region;
let spaces_before_current = single_def.spaces_before;
@ -1953,7 +1953,7 @@ pub fn toplevel_defs<'a>() -> impl Parser<'a, Defs<'a>, EExpr<'a>> {
let start_column = state.column();
let options = ExprParseOptions {
accept_multi_backpassing: false,
accept_multi_backpassing: true,
check_for_arrow: true,
};

View File

@ -0,0 +1,3 @@
main =
arg1, arg2 <- f {}
"Roc <3 Zig!\n"

View File

@ -0,0 +1,67 @@
Defs {
tags: [
Index(2147483648),
],
regions: [
@0-50,
],
space_before: [
Slice(start = 0, length = 0),
],
space_after: [
Slice(start = 0, length = 0),
],
spaces: [],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier(
"main",
),
@12-50 SpaceBefore(
Backpassing(
[
@12-16 Identifier(
"arg1",
),
@18-22 Identifier(
"arg2",
),
],
@26-30 Apply(
@26-27 Var {
module_name: "",
ident: "f",
},
[
@28-30 Record(
[],
),
],
Space,
),
@35-50 SpaceBefore(
Str(
Line(
[
Plaintext(
"Roc <3 Zig!",
),
EscapedChar(
Newline,
),
],
),
),
[
Newline,
],
),
),
[
Newline,
],
),
),
],
}

View File

@ -0,0 +1,3 @@
main =
arg1, arg2 <- f {}
"Roc <3 Zig!\n"

View File

@ -309,6 +309,7 @@ mod test_snapshots {
pass/mixed_docs.expr,
pass/module_def_newline.moduledefs,
pass/multi_backpassing.expr,
pass/multi_backpassing_in_def.moduledefs,
pass/multi_backpassing_with_apply.expr,
pass/multi_char_string.expr,
pass/multiline_string.expr,