You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importlanguage.experimental.captureCheckingtypeFoo1= [R] -> (x: Unit) ->{} Unit// crashes// Or the following variants ...// type Foo2 = [R] -> (x: Unit) ->{cap} Unit// type Foo3 = (c: Int^) -> [R] -> (x: Unit) ->{c} Unit// but the following workstypeFoo4= (c: Int^) -> [R] -> (x0: Unit) -> (x: Unit) ->{c} Unit// ok
Output (click arrow to expand)
exception occurred while typechecking issues/cc-lambda-types.scala
An unhandled exception was thrown in the compiler.
Please file a crash report here:
https://github.com/lampepfl/dotty/issues/new/choose
whilecompiling: issues/cc-lambda-types.scala
during phase: typer
mode: Mode(ImplicitsEnabled)
library version: version 2.13.10
compiler version: version 3.4.0-RC1-bin-SNAPSHOT-nonbootstrapped-git-6dc3737
settings: -classpath /Users/linyxus/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.10/scala-library-2.13.10.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
tree: EmptyTree
tree position: :<unknown>
tree type: <notype>
symbol: val<none>
call site: package<root>inmoduleclass<root>==Source file context for tree position ==Exception in thread "main" scala.MatchError:CapturesAndResult(List(),Ident(Unit)) (of classdotty.tools.dotc.ast.untpd$CapturesAndResult)
at dotty.tools.dotc.ast.desugar$.apply(Desugar.scala:1873)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3161)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3179)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3255)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3259)
at dotty.tools.dotc.typer.Typer.typedType(Typer.scala:3374)
at dotty.tools.dotc.typer.Namer.typedAheadType$$anonfun$1(Namer.scala:1655)
at dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1648)
at dotty.tools.dotc.typer.Namer.typedAheadType(Namer.scala:1655)
at dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1749)
at dotty.tools.dotc.typer.Namer.defDefSig(Namer.scala:1800)
at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:793)
at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:936)
at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:816)
at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:174)
at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:187)
at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:189)
at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:393)
at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:3052)
at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3077)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3178)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3255)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3259)
at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3281)
at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3327)
at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2738)
at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:3099)
at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3103)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3178)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3255)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3259)
at dotty.tools.dotc.typer.Typer.typedRefinedTypeTree(Typer.scala:2149)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3137)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3179)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3255)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3259)
at dotty.tools.dotc.typer.Typer.typedPolyFunction(Typer.scala:1648)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3122)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3179)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3255)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3259)
at dotty.tools.dotc.typer.Typer.typedType(Typer.scala:3374)
at dotty.tools.dotc.typer.Namer.typedAheadType$$anonfun$1(Namer.scala:1655)
at dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1648)
at dotty.tools.dotc.typer.Namer.typedAheadType(Namer.scala:1655)
at dotty.tools.dotc.typer.Namer$TypeDefCompleter.typeSig(Namer.scala:1035)
at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:936)
at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:816)
at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:174)
at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:187)
at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:189)
at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:393)
at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:3052)
at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3077)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3178)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3255)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3259)
at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3281)
at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3327)
at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2738)
at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:3099)
at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3103)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3178)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3255)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3259)
at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3281)
at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3327)
at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2873)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3145)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3179)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3255)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3259)
at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3371)
at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$1(TyperPhase.scala:44)
at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$adapted$1(TyperPhase.scala:50)
at scala.Function0.apply$mcV$sp(Function0.scala:42)
at dotty.tools.dotc.core.Phases$Phase.monitor(Phases.scala:440)
at dotty.tools.dotc.typer.TyperPhase.typeCheck(TyperPhase.scala:50)
at dotty.tools.dotc.typer.TyperPhase.runOn$$anonfun$3(TyperPhase.scala:84)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at scala.collection.immutable.List.foreach(List.scala:333)
at dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:84)
at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:246)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1321)
at dotty.tools.dotc.Run.runPhases$1(Run.scala:262)
at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:270)
at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:279)
at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:71)
at dotty.tools.dotc.Run.compileUnits(Run.scala:279)
at dotty.tools.dotc.Run.compileSources(Run.scala:194)
at dotty.tools.dotc.Run.compile(Run.scala:179)
at dotty.tools.dotc.Driver.doCompile(Driver.scala:37)
at dotty.tools.dotc.Driver.process(Driver.scala:197)
at dotty.tools.dotc.Driver.process(Driver.scala:165)
at dotty.tools.dotc.Driver.process(Driver.scala:177)
at dotty.tools.dotc.Driver.main(Driver.scala:207)
at dotty.tools.dotc.Main.main(Main.scala)
[error] Nonzero exit code returned from runner: 1
[error] (scala3-compiler /Compile/ runMain) Nonzero exit code returned from runner: 1
[error] Totaltime: 1 s, completed Sep6, 2023, 1:46:51AM
The text was updated successfully, but these errors were encountered:
In the example above, the type [R] -> (x: Unit) ->{cap} Unit is desugared into PolyFunction { def apply[R](x: Unit): ^{cap} Unit } where ^{cap} Unit is the temporary tree CapturesAndResult produced by the parser. So the crash seems to be an implementation restriction imposed by our encoding of polyfunctions.
Fix#18518.
It is an implementation restriction that a value parameter has to follow
a type abstraction. So `[X] -> T ->{x} U` should be rejected as a
capturing type follows the type abstraction,but it wasn't. This PR
refines the check in `Parsers.scala` to reject this case properly.
Compiler version
main
Minimized code
Output (click arrow to expand)
The text was updated successfully, but these errors were encountered: