From 7465a0c3ea02f6b2651559b5bfc04d04bc5d9852 Mon Sep 17 00:00:00 2001 From: Asher Frost Date: Wed, 11 Dec 2024 22:09:43 -0500 Subject: [PATCH 1/4] Fixed issue #2457 Commas before function arguement types on lines will no longer give errors. --- crates/compiler/parse/src/type_annotation.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/compiler/parse/src/type_annotation.rs b/crates/compiler/parse/src/type_annotation.rs index ec70c1b10ec..b8c29a7a95c 100644 --- a/crates/compiler/parse/src/type_annotation.rs +++ b/crates/compiler/parse/src/type_annotation.rs @@ -605,7 +605,12 @@ fn expression<'a>( .parse(arena, state, min_indent)?; let (p2, rest, rest_state) = zero_or_more(skip_first( - backtrackable(byte(b',', EType::TFunctionArgument)), + backtrackable( + and( + backtrackable(space0_e(EType::TIndentStart)), + byte(b',', EType::TFunctionArgument) + ) + ), one_of![ map_with_arena( and( From 92ed5a56b7db717f89aba137f31e00223f706ce0 Mon Sep 17 00:00:00 2001 From: Asher Frost Date: Fri, 13 Dec 2024 15:31:57 -0500 Subject: [PATCH 2/4] Reverted removal --- crates/compiler/parse/src/type_annotation.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/compiler/parse/src/type_annotation.rs b/crates/compiler/parse/src/type_annotation.rs index b8c29a7a95c..2158d5b678f 100644 --- a/crates/compiler/parse/src/type_annotation.rs +++ b/crates/compiler/parse/src/type_annotation.rs @@ -606,7 +606,7 @@ fn expression<'a>( let (p2, rest, rest_state) = zero_or_more(skip_first( backtrackable( - and( + skip_first( backtrackable(space0_e(EType::TIndentStart)), byte(b',', EType::TFunctionArgument) ) From 6790e0f5e36c2b6df5f68a83e3b57b2762696ae6 Mon Sep 17 00:00:00 2001 From: Asher Frost Date: Fri, 13 Dec 2024 16:53:08 -0500 Subject: [PATCH 3/4] Changed snapshots to correct syntax --- .../pass/annotate_tuple_func.expr.formatted.roc | 5 +---- .../pass/annotate_tuple_func.expr.result-ast | 13 ++++--------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/annotate_tuple_func.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/annotate_tuple_func.expr.formatted.roc index 8e092a05b1a..110ea9b206a 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/annotate_tuple_func.expr.formatted.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/annotate_tuple_func.expr.formatted.roc @@ -1,5 +1,2 @@ -1 : ( - f, - (ww -> p), -)e +1 : (f, ww -> p)e Mh \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/annotate_tuple_func.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/annotate_tuple_func.expr.result-ast index d284453c3ac..dec314eac6e 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/annotate_tuple_func.expr.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/annotate_tuple_func.expr.result-ast @@ -21,16 +21,11 @@ ), @2-13 Tuple { elems: [ - @3-4 SpaceAfter( - BoundVariable( - "f", - ), - [ - Newline, - ], - ), - @6-11 Function( + @3-11 Function( [ + @3-4 BoundVariable( + "f", + ), @6-8 BoundVariable( "ww", ), From e6389b7b53da169f8000c8a2faef3fc21a63fdfa Mon Sep 17 00:00:00 2001 From: Asher Frost Date: Fri, 13 Dec 2024 20:54:42 -0500 Subject: [PATCH 4/4] Fixed formatting --- crates/compiler/parse/src/type_annotation.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/crates/compiler/parse/src/type_annotation.rs b/crates/compiler/parse/src/type_annotation.rs index 2158d5b678f..e08a1dfe8b6 100644 --- a/crates/compiler/parse/src/type_annotation.rs +++ b/crates/compiler/parse/src/type_annotation.rs @@ -605,12 +605,10 @@ fn expression<'a>( .parse(arena, state, min_indent)?; let (p2, rest, rest_state) = zero_or_more(skip_first( - backtrackable( - skip_first( - backtrackable(space0_e(EType::TIndentStart)), - byte(b',', EType::TFunctionArgument) - ) - ), + backtrackable(skip_first( + backtrackable(space0_e(EType::TIndentStart)), + byte(b',', EType::TFunctionArgument), + )), one_of![ map_with_arena( and(