From 6d704104a5f93fed9341a1846647f90bfef02e41 Mon Sep 17 00:00:00 2001 From: Paul Chiusano Date: Sat, 4 Nov 2023 09:27:25 -0500 Subject: [PATCH] fix #4352 and add regression test --- parser-typechecker/src/Unison/Syntax/TermPrinter.hs | 2 +- unison-src/transcripts-round-trip/main.output.md | 3 +++ unison-src/transcripts-round-trip/reparses-with-same-hash.u | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/parser-typechecker/src/Unison/Syntax/TermPrinter.hs b/parser-typechecker/src/Unison/Syntax/TermPrinter.hs index c9e446777..f1e849241 100644 --- a/parser-typechecker/src/Unison/Syntax/TermPrinter.hs +++ b/parser-typechecker/src/Unison/Syntax/TermPrinter.hs @@ -228,7 +228,7 @@ pretty0 tm' <- pretty0 (ac 10 Normal im doc) tm tp' <- TypePrinter.pretty0 im 0 t pure . paren (p >= 0) $ tm' <> PP.hang (fmt S.TypeAscriptionColon " :") tp' - Int' i -> pure . fmt S.NumericLiteral $ (if i >= 0 then l "+" else mempty) <> l (show i) + Int' i -> pure . fmt S.NumericLiteral . l $ (if i >= 0 then ("+" ++ show i) else (show i)) Nat' u -> pure . fmt S.NumericLiteral . l $ show u Float' f -> pure . fmt S.NumericLiteral . l $ show f -- TODO How to handle Infinity, -Infinity and NaN? Parser cannot parse diff --git a/unison-src/transcripts-round-trip/main.output.md b/unison-src/transcripts-round-trip/main.output.md index 180065700..f8849b363 100644 --- a/unison-src/transcripts-round-trip/main.output.md +++ b/unison-src/transcripts-round-trip/main.output.md @@ -265,6 +265,9 @@ So we can see the pretty-printed output: Some x -> x None -> bug "oops" + fix_4352 : Doc2 + fix_4352 = {{ `` +1 `` }} + Fix_525.bar.quaffle : Nat Fix_525.bar.quaffle = 32 diff --git a/unison-src/transcripts-round-trip/reparses-with-same-hash.u b/unison-src/transcripts-round-trip/reparses-with-same-hash.u index 8b181122c..664fe0265 100644 --- a/unison-src/transcripts-round-trip/reparses-with-same-hash.u +++ b/unison-src/transcripts-round-trip/reparses-with-same-hash.u @@ -466,3 +466,5 @@ test3 = do -- this would previously get printed as `Join.Join` structural type foo.Join = Table | Join Boolean | Values [Nat] + +fix_4352 = {{``+1``}} \ No newline at end of file