Skip to content

Compiler goes OOM/infinite loop after unknown type in extractor #23156

Open
@eejbyfeldt

Description

@eejbyfeldt

Compiler version

3.7.0, 3.7.1-RC1

Minimized code

object Unpack {
  def unapply(e: (Int, Int)): Some[NamedTuple["_1" *: "_2" *: EmptyTuple, Int *: Int *: EmptyTuple]] = ???

  def select[T, R](f: T => R) = ???
  select[(Int, Int), Int] { case Unpack(first, _) => first }
}

Output (click arrow to expand)

-- [E006] Not Found Error: extractor_namedtuple.scala:4:10 -----------------------------------
4 |  ): Some[NamedTuple["_1" *: "_2" *: EmptyTuple, Int *: Int *: EmptyTuple]] = ???
  |          ^^^^^^^^^^
  |          Not found: type NamedTuple - did you mean NamedTuple.type?
  |
  | longer explanation available when compiling with `-explain`

  Exception while compiling extractor_namedtuple.scala

  An unhandled exception was thrown in the compiler.
  Please file a crash report here:
  https://github.com/scala/scala3/issues/new/choose
  For non-enriched exceptions, compile with -Xno-enrich-error-messages.


     while compiling: <no file>
        during phase: parser
                mode: Mode()
     library version: version 2.13.16
    compiler version: version 3.7.0
            settings: 

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
	at dotty.tools.dotc.core.Names$.dotty$tools$dotc$core$Names$$$ensureCapacity(Names.scala:538)
	at dotty.tools.dotc.core.Names$NameTable.enterIfNew(Names.scala:570)
	at dotty.tools.dotc.core.Names$.termName(Names.scala:610)
	at dotty.tools.dotc.core.Names$.termName(Names.scala:636)
	at dotty.tools.dotc.core.StdNames$ScalaTermNames.productAccessorName(StdNames.scala:853)
	at dotty.tools.dotc.core.StdNames$ScalaTermNames.selectorName(StdNames.scala:861)
	at dotty.tools.dotc.typer.Applications$.$anonfun$47(Applications.scala:132)
	at dotty.tools.dotc.typer.Applications$.$anonfun$adapted$3(Applications.scala:132)
	at dotty.tools.dotc.typer.Applications$$$Lambda$817/0x000079d19c3f5750.apply(Unknown Source)
	at scala.collection.Iterator$$anon$9.next(Iterator.scala:584)
	at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:637)
	at scala.collection.immutable.List.prependedAll(List.scala:155)
	at scala.collection.IterableOnceOps.toList(IterableOnce.scala:1446)
	at scala.collection.IterableOnceOps.toList$(IterableOnce.scala:1446)
	at scala.collection.AbstractIterator.toList(Iterator.scala:1306)
	at dotty.tools.dotc.typer.Applications$.productSelectorTypes(Applications.scala:133)
	at dotty.tools.dotc.typer.Applications$UnapplyArgs.getUnapplySelectors$$anonfun$1(Applications.scala:225)
	at dotty.tools.dotc.typer.Applications$UnapplyArgs$$Lambda$822/0x000079d19c3f99b0.apply(Unknown Source)
	at scala.Option.getOrElse(Option.scala:201)
	at dotty.tools.dotc.typer.Applications$UnapplyArgs.getUnapplySelectors(Applications.scala:227)
	at dotty.tools.dotc.typer.Applications$UnapplyArgs.$init$$$anonfun$2(Applications.scala:258)
	at dotty.tools.dotc.typer.Applications$UnapplyArgs$$Lambda$820/0x000079d19c3f8d88.apply(Unknown Source)
	at scala.Option.getOrElse(Option.scala:201)
	at dotty.tools.dotc.typer.Applications$UnapplyArgs.<init>(Applications.scala:267)
	at dotty.tools.dotc.typer.Applications.typedUnApply(Applications.scala:1679)
	at dotty.tools.dotc.typer.Applications.typedUnApply$(Applications.scala:465)
	at dotty.tools.dotc.typer.Typer.typedUnApply(Typer.scala:154)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3560)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3648)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3725)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3730)
	at dotty.tools.dotc.typer.Typer.typedPattern(Typer.scala:3862)

Increasing heap size just makes it run for a really long time.

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