From 008a9c3e3709f3eec4e28f305664c99c7f3d635c Mon Sep 17 00:00:00 2001 From: Gabriel Gonzalez Date: Mon, 11 Nov 2019 12:43:29 -0800 Subject: [PATCH] Fix parser for expressions with nested annotations (#1527) Fixes https://github.com/dhall-lang/dhall-haskell/issues/1467 We now no longer replace an annotation if one was already present --- dhall/src/Dhall/Parser/Expression.hs | 6 +++--- dhall/tests/format/nestedAnnotationA.dhall | 1 + dhall/tests/format/nestedAnnotationB.dhall | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 dhall/tests/format/nestedAnnotationA.dhall create mode 100644 dhall/tests/format/nestedAnnotationB.dhall diff --git a/dhall/src/Dhall/Parser/Expression.hs b/dhall/src/Dhall/Parser/Expression.hs index 86ab986..43387ee 100644 --- a/dhall/src/Dhall/Parser/Expression.hs +++ b/dhall/src/Dhall/Parser/Expression.hs @@ -273,11 +273,11 @@ parsers embedded = Parsers {..} nonemptyWhitespace b <- expression case shallowDenote a of - ListLit _ [] -> + ListLit Nothing [] -> return (ListLit (Just b) []) - Merge c d _ -> + Merge c d Nothing -> return (Merge c d (Just b)) - ToMap c _ -> + ToMap c Nothing -> return (ToMap c (Just b)) _ -> return (Annot a b) diff --git a/dhall/tests/format/nestedAnnotationA.dhall b/dhall/tests/format/nestedAnnotationA.dhall new file mode 100644 index 0000000..c8dc65f --- /dev/null +++ b/dhall/tests/format/nestedAnnotationA.dhall @@ -0,0 +1 @@ +([] : a) : b diff --git a/dhall/tests/format/nestedAnnotationB.dhall b/dhall/tests/format/nestedAnnotationB.dhall new file mode 100644 index 0000000..c8dc65f --- /dev/null +++ b/dhall/tests/format/nestedAnnotationB.dhall @@ -0,0 +1 @@ +([] : a) : b