-
Notifications
You must be signed in to change notification settings - Fork 165
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
Printer for nonempty lists: "pattern matching is not exhaustive" warning in ocaml backend (suppressed in Haskell backend) #384
Comments
Since In #371 it is suggested that One could of course silence the Ocaml warning by adding a case for the empty list that creates the empty document. This could be beneficial if the programmer wants to create empty lists in the AST (only not via parsing). However, if the programmer rather wants to insist that lists there can indeed not be empty, then it is cleaner to leave the match partial so that the program crashes if an empty list should be encountered. (Well, maybe you do not want to crash in the printer...) |
Ah sorry I thought it was a problem with my certain case and not generally connected to One could implement a nonempty list, but that seem overkill for me for the case of the printer. |
The Haskell backend also creates an incomplete match, but suppresses the warning. |
There is a related problem with lists of precedence categories:
Generated printer in OCaml (same in Haskell):
This would be a bit harder to fix than the OP. |
PR #385 would make the OP go away, but not #384 (comment). So I am not sure whether to merge this. Alternatively, maybe the warning could be switched off in OCaml. |
As for disabling the warning in OCaml, to catch the case and throw an error seems to be the most straightforward way However apparently it is also possible to disable the warning just for this part of the code by adding (generated Printer in Ocaml)
|
…ists We make the lowest precedence the catch-all.
Thanks for the research @JoAllg! I am now also fixing the problem with the precedence category lists, so the pattern matches should be complete now for both OCaml and Haskell. |
…ists We make the lowest precedence the catch-all.
Background: I want to have a list of
Data
category elements with at least two elements. The easiest working solution I found isHowever, here are two other ways i thought of, that cause a "pattern matching is not exhaustive" warning in the ocaml / ocaml-menhir backend:
The full error message:
The second gramar that causes the same error:
The warning does not occur if
nonempty
is removed.The text was updated successfully, but these errors were encountered: