From 7f15f73fd614b403ebe8267b6f1ab76813858edb Mon Sep 17 00:00:00 2001 From: Troels Henriksen Date: Sat, 11 Jan 2025 11:21:03 +0100 Subject: [PATCH] futhark fmt: handle comment-only programs better. --- src/Futhark/Fmt/Printer.hs | 1 + tests_fmt/expected/header_comment.fut | 1 + tests_fmt/header_comment.fut | 1 + 3 files changed, 3 insertions(+) create mode 100644 tests_fmt/expected/header_comment.fut create mode 100644 tests_fmt/header_comment.fut diff --git a/src/Futhark/Fmt/Printer.hs b/src/Futhark/Fmt/Printer.hs index 027d37d7cd..32fc3dfd76 100644 --- a/src/Futhark/Fmt/Printer.hs +++ b/src/Futhark/Fmt/Printer.hs @@ -619,6 +619,7 @@ instance Format UncheckedDec where addComments loc $ "import" <+> "\"" <> fmtPretty path <> "\"" instance Format UncheckedProg where + fmt (Prog Nothing []) = popComments fmt (Prog Nothing decs) = sepDecs fmt decs popComments fmt (Prog (Just dc) decs) = fmt dc sepDecs fmt decs popComments diff --git a/tests_fmt/expected/header_comment.fut b/tests_fmt/expected/header_comment.fut new file mode 100644 index 0000000000..f8517645df --- /dev/null +++ b/tests_fmt/expected/header_comment.fut @@ -0,0 +1 @@ +-- # This comment is the first and only thing in this file. diff --git a/tests_fmt/header_comment.fut b/tests_fmt/header_comment.fut new file mode 100644 index 0000000000..f8517645df --- /dev/null +++ b/tests_fmt/header_comment.fut @@ -0,0 +1 @@ +-- # This comment is the first and only thing in this file.