Skip to content

Tuple.Head being unable to work with NonEmptyTuple in match types. #17186

Closed
@Decel

Description

@Decel

Compiler version

3.3.1-RC1

Minimized code

type second[X <: Tuple2[Any, Any]] = Tuple.Head[Tuple.Tail[X]] // error
type middle[X <: Tuple3[Any, Any, Any]] = Tuple.Head[Tuple.Tail[X]] // error

val a: Tuple.Head[Tuple.Tail[Tuple2[Int, String]]] = ??? // works
val b: Tuple.Head[Tuple.Tail[Tuple3[Int, String, Boolean]]] = ??? // works

Output

-- [E057] Type Mismatch Error: ---------------------------------------------------
1 |type second[X <: Tuple2[Any, Any]] = Tuple.Head[Tuple.Tail[X]]
  |                                                ^
  | Type argument Tuple.Tail[X] does not conform to upper bound NonEmptyTuple
  |
  | Note: a match type could not be fully reduced:
  |
  |   trying to reduce  Tuple.Tail[X]
  |   failed since selector X
  |   does not match  case _ *: xs => xs
  |   and cannot be shown to be disjoint from it either.
  |
  | longer explanation available when compiling with `-explain`

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