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

Confusing description of missing cases when matching values #186

Open
avh4 opened this issue Dec 2, 2016 · 0 comments
Open

Confusing description of missing cases when matching values #186

avh4 opened this issue Dec 2, 2016 · 0 comments
Labels

Comments

@avh4
Copy link
Member

avh4 commented Dec 2, 2016

With this code:

f = 
  case ("", "") of
    ("a", "b") -> ()
    ("c", "d") -> ()
    (_, "b") -> ()
    ("a", _) -> ()
    ("e", "z") -> ()

The error is

-- MISSING PATTERNS ------------------------------------------------------------

This `case` does not have branches for all possibilities.

 5|>  case ("", "") of
 6|>    ("a", "b") -> ()
 7|>    ("c", "d") -> ()
 8|>    (_, "b") -> ()
 9|>    ("a", _) -> ()
10|>    ("e", "z") -> ()

You need to account for the following values:

    (<values besides "a", "c", and "e">, <values besides "b">)
    (<values besides "a" and "c">, <values besides "b" and "z">)
    (<values besides "a" and "e">, <values besides "b" and "d">)
    (<values besides "a">, <values besides "b", "d", and "z">)
    ...

Add branches to cover each of these patterns!

If you are seeing this error for the first time, check out these hints:
<https://github.com/elm-lang/elm-compiler/blob/0.18.0/hints/missing-patterns.md>
The recommendations about wildcard patterns and `Debug.crash` are important!

The list of missing values is confusing, and is entirely phrased as negatives, which makes it hard to figure out which cases need to be added. A better message would list the missing values as:

You need to account for the following values:

    ( "c", <values besides "b" and "d"> )
    ( "e", <values besides "b" and "z"> )
    ( <values besides "a", "c", "e">, <values besides "b"> )
@evancz evancz added the patterns label Feb 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants