From 1d3aa261931d0c8fbac6d8f40b66fe46f9408fec Mon Sep 17 00:00:00 2001 From: Pierre-Henri Trivier Date: Fri, 4 Mar 2022 23:35:53 +0100 Subject: [PATCH] Fixes #2586 --- compiler/fmt/src/annotation.rs | 3 +++ compiler/fmt/tests/test_fmt.rs | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/compiler/fmt/src/annotation.rs b/compiler/fmt/src/annotation.rs index 4380af17e2..4c389f7147 100644 --- a/compiler/fmt/src/annotation.rs +++ b/compiler/fmt/src/annotation.rs @@ -293,6 +293,9 @@ impl<'a> Formattable for TypeAnnotation<'a> { SpaceBefore(ann, spaces) => { buf.newline(); + + buf.indent(indent); + fmt_comments_only(buf, spaces.iter(), NewlineAt::Bottom, indent); ann.format_with_options(buf, parens, Newlines::No, indent) } diff --git a/compiler/fmt/tests/test_fmt.rs b/compiler/fmt/tests/test_fmt.rs index a49914abce..edea7957d3 100644 --- a/compiler/fmt/tests/test_fmt.rs +++ b/compiler/fmt/tests/test_fmt.rs @@ -2984,6 +2984,18 @@ mod test_fmt { )); } + #[test] + fn multiline_higher_order_function() { + expr_formats_same(indoc!( + r#" + foo : + (Str -> Bool) -> Bool + + 42 + "# + )); + } + #[test] /// Test that everything under examples/ is formatted correctly /// If this test fails on your diff, it probably means you need to re-format the examples.