Skip to content
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

Skolem types in capture sets crash the compiler #19470

Closed
Linyxus opened this issue Jan 18, 2024 · 0 comments · Fixed by #19472
Closed

Skolem types in capture sets crash the compiler #19470

Linyxus opened this issue Jan 18, 2024 · 0 comments · Fixed by #19472
Labels
area:experimental:cc Capture checking related cc-experiment Intended to be merged with cc-experiment branch on origin itype:bug itype:crash
Milestone

Comments

@Linyxus
Copy link
Contributor

Linyxus commented Jan 18, 2024

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

@Linyxus Linyxus added itype:bug cc-experiment Intended to be merged with cc-experiment branch on origin labels Jan 18, 2024
@Gedochao Gedochao added itype:crash area:experimental:cc Capture checking related labels Jan 18, 2024
odersky added a commit to dotty-staging/dotty that referenced this issue Jan 18, 2024
odersky added a commit to dotty-staging/dotty that referenced this issue Jan 18, 2024
@Kordyjan Kordyjan added this to the 3.4.1 milestone Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:experimental:cc Capture checking related cc-experiment Intended to be merged with cc-experiment branch on origin itype:bug itype:crash
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants