Skip to content

Improve error: the pattern contains an unaccounted type parameter #22943

Open
@TomasMikula

Description

@TomasMikula

Compiler version

3.6.4

Minimized code

sealed trait KV[K, V]
sealed trait Append[Init, KV]

type KeysOf[KVs] = KVs match
  case KV[k, v] => k
  case Append[init, KV[k, v]] => KeysOf[init] | k

// OK
summon[KeysOf[KV["x", Int]] =:= "x"]

// Error
summon[KeysOf[Append[KV["x", Int], KV["y", String]]] =:= ("x" | "y")]

Output

The match type contains an illegal case:
    case Append[init, KV[k, v]] => KeysOf[init] | k
The pattern contains an unaccounted type parameter `k`.
(this error can be ignored for now with `-source:3.3`)

https://scastie.scala-lang.org/6ZDIroNFQQuOwgG78Ju83w

Expectation

Should compile.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions