Skip to content

Skolem types in capture sets crash the compiler #19470

Closed
@Linyxus

Description

@Linyxus

Compiler version

main

Minimized code

import language.experimental.captureChecking
trait IO
case class Inv[X](x: X)

def foo(x: IO^): Inv[IO^{x}] = Inv(x)

def main(io: IO^): Unit =
  def test(f: () => IO^) =
    List(foo(f()))

Output

[info] running (fork) dotty.tools.dotc.Main -d /Users/linyxus/Workspace/dotty/compiler/../out/default-last-scalac-out.jar -classpath /Users/linyxus/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.12/scala-library-2.13.12.jar:/Users/linyxus/Workspace/dotty/library/../out/bootstrap/scala3-library-bootstrapped/scala-3.4.0-RC1-bin-SNAPSHOT-nonbootstrapped/scala3-library_3-3.4.0-RC1-bin-SNAPSHOT.jar -color:never issues/wildcard-captures.scala

  unhandled exception while running cc on issues/wildcard-captures.scala

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

     while compiling: issues/wildcard-captures.scala
        during phase: cc
                mode: Mode(ImplicitsEnabled)
     library version: version 2.13.12
    compiler version: version 3.4.0-RC1-bin-SNAPSHOT-nonbootstrapped-git-2945fd1
            settings: -classpath /Users/linyxus/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.12/scala-library-2.13.12.jar:/Users/linyxus/Workspace/dotty/library/../out/bootstrap/scala3-library-bootstrapped/scala-3.4.0-RC1-bin-SNAPSHOT-nonbootstrapped/scala3-library_3-3.4.0-RC1-bin-SNAPSHOT.jar -color never -d /

Exception in thread "main" dotty.tools.dotc.cc.IllegalCaptureRef: TypeVar(TypeParamRef((param)1) -> SkolemType(564766469))
	at dotty.tools.dotc.cc.CaptureOps$package$.toCaptureRef(CaptureOps.scala:87)
	at dotty.tools.dotc.cc.CaptureOps$package$.$anonfun$1(CaptureOps.scala:96)
	at scala.collection.immutable.List.map(List.scala:246)
	at dotty.tools.dotc.cc.CaptureOps$package$.toCaptureSet(CaptureOps.scala:96)
	at dotty.tools.dotc.cc.Setup$$anon$3.apply(Setup.scala:289)
	at dotty.tools.dotc.core.Types$TypeMap.op$proxy17$1(Types.scala:6019)
	at dotty.tools.dotc.core.Types$TypeMap.mapArg(Types.scala:6019)
	at dotty.tools.dotc.core.Types$TypeMap.mapArgs(Types.scala:6023)
	at dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:6060)
	at dotty.tools.dotc.cc.Setup$$anon$3.recur(Setup.scala:278)
	at dotty.tools.dotc.cc.Setup$$anon$3.apply(Setup.scala:302)
	at dotty.tools.dotc.cc.Setup.dotty$tools$dotc$cc$Setup$$transformExplicitType(Setup.scala:305)
	at dotty.tools.dotc.cc.Setup.dotty$tools$dotc$cc$Setup$$transformTT(Setup.scala:316)
	at dotty.tools.dotc.cc.Setup$$anon$5.traverse(Setup.scala:419)
	at dotty.tools.dotc.ast.tpd$TreeTraverserWithPreciseImportContexts.recur$3(tpd.scala:1295)
	at dotty.tools.dotc.ast.tpd$TreeTraverserWithPreciseImportContexts.apply(tpd.scala:1298)
	at dotty.tools.dotc.ast.tpd$TreeTraverserWithPreciseImportContexts.apply(tpd.scala:1290)
	at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1679)
	at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.traverseChildren(Trees.scala:1797)
	at dotty.tools.dotc.cc.Setup$$anon$5.traverse(Setup.scala:422)
	at dotty.tools.dotc.cc.Setup$$anon$5.traverse(Setup.scala:397)
	at dotty.tools.dotc.ast.tpd$TreeTraverserWithPreciseImportContexts.recur$3(tpd.scala:1295)
... (More stack trace)

Expectation

The compiler should not crash.

/cc @odersky

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions