Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle empty lists without annotations as parse errors #1957

Merged
merged 2 commits into from
Jul 30, 2020

Conversation

sjakobi
Copy link
Collaborator

@sjakobi sjakobi commented Jul 30, 2020

Here are a few samples of the parse errors:

⊢ []

Error: Invalid input

(input):2:1:
  |
2 | <empty line>
  | ^
Empty list literal without annotation

⊢ ([]) : T

Error: Invalid input

(input):1:4:
  |
1 | ([]) : T
  |    ^
Empty list literal without annotation

⊢ { c = [] }

Error: Invalid input

(input):1:10:
  |
1 | { c = [] }
  |          ^
Empty list literal without annotation

@sjakobi sjakobi force-pushed the sjakobi/list-annotation-parsing branch 2 times, most recently from 9036ee3 to 453d309 Compare July 30, 2020 12:35
@sjakobi
Copy link
Collaborator Author

sjakobi commented Jul 30, 2020

I'm still getting a doctest failure that I'm not sure how to fix:

/home/simon/src/dhall-haskell/dhall/src/Dhall/Tutorial.hs:452: failure in expression `input auto "[]" :: IO (Vector Natural)'
expected: "*** Exception:"
          "...Error...: Invalid input"
          "..."
          "(input):1:3:"
          "  |"
          "1 | []"
          "  |   ^"
          "Empty list literal without annotation"
 but got: "*** Exception: "
          "\ESC[1;31mError\ESC[0m: Invalid input"
          ""
          "(input):1:3:"
          "  |"
          "1 | []"
          "  |   ^"
          "Empty list literal without annotation"
          ""

Is there a good way to change the example so we don't get the escape codes?

@Gabriella439
Copy link
Collaborator

@sjakobi: The issue isn't the escape codes since those are handled by the ... in the sample doctest output. The problem is that (for some reason) parse errors have an additional space after the *** Exception: and the original type error did not.

@sjakobi sjakobi force-pushed the sjakobi/list-annotation-parsing branch from 453d309 to 6ec8417 Compare July 30, 2020 15:43
@sjakobi
Copy link
Collaborator Author

sjakobi commented Jul 30, 2020

@sjakobi: The issue isn't the escape codes since those are handled by the ... in the sample doctest output. The problem is that (for some reason) parse errors have an additional space after the *** Exception: and the original type error did not.

Oh! Interestingly, fixing that alone isn't sufficient. Apparently doctest can handle that trailing whitespace just fine.

The real problem was a missing line at the end of the output, which I fixed with

--- a/dhall/src/Dhall/Tutorial.hs
+++ b/dhall/src/Dhall/Tutorial.hs
@@ -458,6 +458,7 @@ import Dhall
 -- 1 | []
 --   |   ^
 -- Empty list literal without annotation
+-- ...
 --
 -- Also, list elements must all have the same type.  You will get an error if
 -- you try to store elements of different types in a list:

@sjakobi sjakobi added merge me and removed merge me labels Jul 30, 2020
@sjakobi
Copy link
Collaborator Author

sjakobi commented Jul 30, 2020

I was wondering whether we need to change anything about the MissingListType type error. It's probably still reachable in some way though, so I'll leave it there for now.

@mergify mergify bot merged commit 97ff185 into master Jul 30, 2020
@mergify mergify bot deleted the sjakobi/list-annotation-parsing branch July 30, 2020 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants