Skip to content

Unreasonably slow (or even non-terminating) compilation of pattern match involving GADT reasoning on nested types #16785

Closed
@TomasMikula

Description

@TomasMikula

Compiler version

3.2.2
3.3.0-RC2

Reproduction steps

git clone https://github.com/TomasMikula/libretto.git
cd libretto
git checkout 075f9f1911652ccaaa77dbf16e0b35ebd4a9dfc3
sbt core/compile

Note that I hit this bug in the middle of a refactoring session, so most likely the code should not compile just yet.
It is hard to minimize, because whatever I undo, I do get an actual compiler error. I'm hoping you could detect where it's looping, anyway.

UPDATE: Here's a minimization:

class VarImpl[P, A]()

class ContextImpl[Var[_]]()

trait Lambdas[F[_, _], P] {

  type Var[A] = VarImpl[P, A]

}

class LambdasImpl[F[_, _], P] extends Lambdas[F, P] {

  opaque type Context = ContextImpl[Var]

  sealed trait Foo[A]
  case class Bar[T, U]() extends Foo[F[Var[T], Var[U]]]

  def go[X](that: Foo[Var[X]]): Unit =
    that match
      case _ => ()
}

Output

After a while, compilation hangs with 100% of 1 CPU core.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions