Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
eejbyfeldt opened this issue May 14, 2025 · 1 comment
Open

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

eejbyfeldt opened this issue May 14, 2025 · 1 comment
Labels
area:named-tuples Issues tied to the named tuples feature. area:parser itype:bug itype:compiler hangs Issues where the compiler hangs. itype:crash

Comments

@eejbyfeldt
Copy link

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.

@eejbyfeldt eejbyfeldt added itype:bug itype:crash stat:needs triage Every issue needs to have an "area" and "itype" label labels May 14, 2025
@eejbyfeldt
Copy link
Author

Discovered while minimizing #23155

Not sure if it related?

@Gedochao Gedochao added area:parser itype:compiler hangs Issues where the compiler hangs. area:named-tuples Issues tied to the named tuples feature. and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:named-tuples Issues tied to the named tuples feature. area:parser itype:bug itype:compiler hangs Issues where the compiler hangs. itype:crash
Projects
None yet
Development

No branches or pull requests

2 participants