From d494cf71cb9793ce484254239919b209d84cc24f Mon Sep 17 00:00:00 2001 From: Paul Chiusano Date: Thu, 7 Sep 2023 17:13:51 -0500 Subject: [PATCH] fix regression reported by @runarorama --- .../src/Unison/Syntax/TermPrinter.hs | 2 +- unison-src/transcripts-round-trip/main.md | 6 ++--- .../transcripts-round-trip/main.output.md | 23 +++++++++++++++---- unison-src/transcripts-round-trip/reparses.u | 14 +++++++++++ 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/parser-typechecker/src/Unison/Syntax/TermPrinter.hs b/parser-typechecker/src/Unison/Syntax/TermPrinter.hs index db5037fa3d..c9e446777f 100644 --- a/parser-typechecker/src/Unison/Syntax/TermPrinter.hs +++ b/parser-typechecker/src/Unison/Syntax/TermPrinter.hs @@ -1931,7 +1931,7 @@ toDocVerbatim ppe (App' (Ref' r) (toDocWord ppe -> Just txt)) toDocVerbatim _ _ = Nothing toDocEval :: (Var v) => PrettyPrintEnv -> Term3 v PrintAnnotation -> Maybe (Term3 v PrintAnnotation) -toDocEval ppe (App' (Ref' r) (Delay' tm)) +toDocEval ppe (App' (Ref' r) (DDelay' tm)) | nameEndsWith ppe ".docEval" r = Just tm | r == _oldDocEval = Just tm toDocEval _ _ = Nothing diff --git a/unison-src/transcripts-round-trip/main.md b/unison-src/transcripts-round-trip/main.md index 4f979004b7..99a3add2ae 100644 --- a/unison-src/transcripts-round-trip/main.md +++ b/unison-src/transcripts-round-trip/main.md @@ -80,11 +80,9 @@ x = () .a3_old> delete.namespace.force lib.builtin ``` -These are currently all expected to have different hashes on round trip, though we'd prefer if they round tripped with the same hash. +These are currently all expected to have different hashes on round trip. -NOTE, since we don't currently have anything that round trips with a different hash, this fails. If you find an example that reparses with a different hash, add it to `reparses.u` and change this stanza to `ucm` rather than `ucm:error`. - -```ucm:error +```ucm .> diff.namespace a3 a3_old ``` diff --git a/unison-src/transcripts-round-trip/main.output.md b/unison-src/transcripts-round-trip/main.output.md index f3bccc4b99..1800657009 100644 --- a/unison-src/transcripts-round-trip/main.output.md +++ b/unison-src/transcripts-round-trip/main.output.md @@ -641,19 +641,34 @@ x = () Put definitions in here that are expected to parse with a different hash after pretty-printing. """ + + sloppyDocEval : Doc2 + sloppyDocEval = + use Nat + + {{ + Here's an example of an eval block that's technically a + lambda but should print as a backticked block (since old + docs in the wild still use this format). + + ``` + 1 + 1 + ``` + }} You can edit them there, then do `update` to replace the definitions currently in this namespace. ``` -These are currently all expected to have different hashes on round trip, though we'd prefer if they round tripped with the same hash. - -NOTE, since we don't currently have anything that round trips with a different hash, this fails. If you find an example that reparses with a different hash, add it to `reparses.u` and change this stanza to `ucm` rather than `ucm:error`. +These are currently all expected to have different hashes on round trip. ```ucm .> diff.namespace a3 a3_old - The namespaces are identical. + Updates: + + 1. sloppyDocEval : Doc2 + ↓ + 2. sloppyDocEval : Doc2 ``` ## Other regression tests not covered by above diff --git a/unison-src/transcripts-round-trip/reparses.u b/unison-src/transcripts-round-trip/reparses.u index 103c6aeb34..aea55da4c7 100644 --- a/unison-src/transcripts-round-trip/reparses.u +++ b/unison-src/transcripts-round-trip/reparses.u @@ -3,3 +3,17 @@ explanationOfThisFile = """ Put definitions in here that are expected to parse with a different hash after pretty-printing. """ + +-- This is expected to round trip with the ``` syntax, +-- even though the original didn't use that syntax and +-- defined the eval block with a lambda rather than a delay. +sloppyDocEval = + docUntitledSection [ + docParagraph [ + docWord "Here's an example of an eval block that's", + docWord "technically a lambda but should print as a", + docWord "backticked block (since old docs in the wild", + docWord "still use this format)." + ], + docEval (_ -> 1 Nat.+ 1) + ]