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

Support for refutation cases in pattern matching #1350

Closed
hcarty opened this issue Aug 3, 2017 · 2 comments · Fixed by #2765
Closed

Support for refutation cases in pattern matching #1350

hcarty opened this issue Aug 3, 2017 · 2 comments · Fixed by #2765
Labels
KIND: FEATURE REQUEST Parser parsing reason code into an AST

Comments

@hcarty
Copy link
Contributor

hcarty commented Aug 3, 2017

http://caml.inria.fr/pub/docs/manual-ocaml/extn.html#sec238 -- see the subsection titled "Refutation cases and redundancy"

Something along the lines of:

switch x {
| A -> /* Handle this case */
| B -> /* Handle this case */
| _ -> . /* States (with a check by the type system) that this case isn't possible */
}
@glennsl
Copy link
Contributor

glennsl commented Mar 7, 2020

Surprised to see that this still isn't supported. Are there any workarounds for this? I've tried various forms of type annotations, but that doesn't seem to be sufficient. I guess I could either disable warning 8 or just convert the whole module implementation to OCaml.

@rdavison
Copy link

rdavison commented Mar 7, 2020

@glennsl Been hitting this issue as well. You could also disable warning 56.

type t(_) =
  | A : t(int);

[@warning "-56"];

let foo = (x: t(float)) =>
  switch(x) {
  | _ => assert(false)
  };

[@warning "+56"];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
KIND: FEATURE REQUEST Parser parsing reason code into an AST
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants