Skip to content

irreducible match types should be type errors #10747

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

Closed
tpolecat opened this issue Dec 10, 2020 · 1 comment
Closed

irreducible match types should be type errors #10747

tpolecat opened this issue Dec 10, 2020 · 1 comment

Comments

@tpolecat
Copy link

tpolecat commented Dec 10, 2020

Minimized code

type Foo[A] = A match {
  case Int => String
}

type B = Foo[Boolean]

Output

// code compiles fine

Expectation

It seems to me that the concrete instantiation Foo[Boolean] should be an immediate type error (as happens when an invalid type argument is provided for a bounded type parameter), ideally with an explanation of the reduction failure.

More generally it should be a type error if a term somehow (by inference) ends up with a concretely-instantiated but irreducible match type. The alternative (as now) is that nonsensical types propagate and users have few tools at their disposal to figure out what happened.

I discussed this briefly with @smarter and I understand that it's complicated, but at least in the concrete case I think the compiler could be more helpful.

@OlivierBlanvillain
Copy link
Contributor

Related to #7951

OlivierBlanvillain added a commit to dotty-staging/dotty that referenced this issue Jun 9, 2021
OlivierBlanvillain added a commit to dotty-staging/dotty that referenced this issue Jun 9, 2021
OlivierBlanvillain added a commit to dotty-staging/dotty that referenced this issue Jun 9, 2021
OlivierBlanvillain added a commit to dotty-staging/dotty that referenced this issue Jun 11, 2021
OlivierBlanvillain added a commit to dotty-staging/dotty that referenced this issue Jul 30, 2021
OlivierBlanvillain added a commit to dotty-staging/dotty that referenced this issue Sep 7, 2021
anatoliykmetyuk added a commit that referenced this issue Sep 14, 2021
Fix #10747: Raise type error on unreducible match type
anatoliykmetyuk pushed a commit to dotty-staging/dotty that referenced this issue Sep 14, 2021
@dwijnand dwijnand added this to the 3.1.0 milestone Sep 14, 2021
Kordyjan added a commit that referenced this issue Sep 16, 2021
[Backport] Fix #10747: Raise type error on unreducible match type
olsdavis pushed a commit to olsdavis/dotty that referenced this issue Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants