Skip to content

irreducible match types should be type errors #10747

Closed
@tpolecat

Description

@tpolecat

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.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions