Skip to content

Commit

Permalink
Fix parsing of //\\ (#666)
Browse files Browse the repository at this point in the history
The issue was that the parser was attempting to parse // first, which
will succeed on the prefix of //\\, then the parser will get an error
because it expects a sub expression but the input is \\.
  • Loading branch information
sofia-rose authored and Gabriella439 committed Oct 30, 2018
1 parent aecfbc9 commit 9d0fd42
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions dhall/dhall.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Extra-Source-Files:
Prelude/Monoid
tests/format/*.dhall
tests/normalization/tutorial/combineTypes/*.dhall
tests/normalization/tutorial/prefer/*.dhall
tests/normalization/tutorial/projection/*.dhall
tests/normalization/tutorial/access/*.dhall
tests/normalization/*.dhall
Expand Down
4 changes: 2 additions & 2 deletions dhall/src/Dhall/Parser/Expression.hs
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ completeExpression embedded = completeExpression_
<|> Combine <$ _combine

precedence2Operator =
Prefer <$ _prefer
<|> CombineTypes <$ _combineTypes
CombineTypes <$ _combineTypes
<|> Prefer <$ _prefer
<|> NaturalTimes <$ _times
<|> BoolNE <$ _notEqual

Expand Down
2 changes: 2 additions & 0 deletions dhall/tests/Normalization.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ tutorialExamples :: TestTree
tutorialExamples =
testGroup "Tutorial examples"
[ shouldNormalize "" "./tutorial/combineTypes/0"
, shouldNormalize "//\\\\" "./tutorial/combineTypes/1"
, shouldNormalize "//" "./tutorial/prefer/0"
, shouldNormalize "projection" "./tutorial/projection/0"
, shouldNormalize "access record" "./tutorial/access/0"
, shouldNormalize "access union" "./tutorial/access/1"
Expand Down
1 change: 1 addition & 0 deletions dhall/tests/normalization/tutorial/combineTypes/1A.dhall
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ foo : { bar : Text } } //\\ { foo : { baz : Bool }, qux : Integer }
1 change: 1 addition & 0 deletions dhall/tests/normalization/tutorial/combineTypes/1B.dhall
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ foo : { bar : Text, baz : Bool }, qux : Integer }
1 change: 1 addition & 0 deletions dhall/tests/normalization/tutorial/prefer/0A.dhall
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ foo = 1, bar = "ABC" } // { baz = True }
1 change: 1 addition & 0 deletions dhall/tests/normalization/tutorial/prefer/0B.dhall
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ bar = "ABC", baz = True, foo = 1 }

0 comments on commit 9d0fd42

Please sign in to comment.