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

Match types could give better error diagnostics #12049

Closed
odersky opened this issue Apr 11, 2021 · 0 comments · Fixed by #12053
Closed

Match types could give better error diagnostics #12049

odersky opened this issue Apr 11, 2021 · 0 comments · Fixed by #12053

Comments

@odersky
Copy link
Contributor

odersky commented Apr 11, 2021

If a match type does not reduce, it simply gets stuck, and we are left with the original type. For instance

trait A
trait B
type M[X] = X match
  case A => Int
  case B => String
val x: String = ??? : M[B]

gives the error message:

6 |val x: String = ??? : M[B]
  |                ^^^^^^^^^^
  |                Found:    M[B]
  |                Required: String

This is not very helpful. It would be great if we could get a more precise diagnostic why the match type reduction did not succeed.
Something like:

6 |val x: String = ??? : M[B]
  |                ^^^^^^^^^^
  |                Found:    M[B]
  |                Required: String

Note: `M[B]` could not be reduced. Reduction got stuck at the case

    case A => Int

Here the selector `B` type does not match `A` but I could not prove that it is disjoint from it either.
Hence, I could not proceed to the next case.

It would be great if we could get error messages like that for the various reasons for getting stuck. Also, if a recursive invocation gets stuck it would be great to see a stack trace of how we got there.

This is sort of similar to the improvements we made for diagnosing implicits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants