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

Compiler crash when context bound is used inside type lambda #22552

Open
t9dupuy opened this issue Feb 7, 2025 · 1 comment · May be fixed by #22659
Open

Compiler crash when context bound is used inside type lambda #22552

t9dupuy opened this issue Feb 7, 2025 · 1 comment · May be fixed by #22659
Assignees
Labels

Comments

@t9dupuy
Copy link

t9dupuy commented Feb 7, 2025

Compiler version

3.6.3

Minimized code

trait Foo:
  type TC[T]
  type A[X: TC]                 // error (expected)
  type C = [X: TC] =>> List[X]  // crash

Output (click arrow to expand)

[info] compiling 1 Scala source to D:\scala\canopy\target\scala-3.6.3\classes ...
[info] 
[info]   exception occurred while typechecking D:\scala\canopy\src\main\scala\Main.scala
[info] root / Compile / compileIncremental 0s
[info]   An unhandled exception was thrown in the compiler.
[info]   Please file a crash report here:
[info]   https://github.com/scala/scala3/issues/new/choose
[info]   For non-enriched exceptions, compile with -Xno-enrich-error-messages.
[info]
[info]
[info]      while compiling: D:\scala\canopy\src\main\scala\Main.scala
[info]         during phase: typer
[info]                 mode: Mode(ImplicitsEnabled,ReadPositions)
[info]      library version: version 2.13.15
[info]     compiler version: version 3.6.3
[info]             settings: -Xsemanticdb true -classpath D:\scala\canopy\target\scala-3.6.3\classes;D:\packages\coursier\https\repo1.maven.org\maven2\org\scala-lang\scala3-library_3\3.6.3\scala3-library_3-3.6.3.jar;D:\packages\coursier\https\repo1.maven.org\maven2\com\sourcegraph\semanticdb-javac\0.10.3\semanticdb-javac-0.10.3.jar;D:\packages\coursier\https\repo1.maven.org\maven2\org\scala-lang\scala-library\2.13.15\scala-library-2.13.15.jar -d D:\scala\canopy\target\scala-3.6.3\classes -semanticdb-target D:\scala\canopy\target\scala-3.6.3\meta
[error] ## Exception when compiling 2 sources to D:\scala\canopy\target\scala-3.6.3\classes
[error] java.lang.IllegalArgumentException: Thicket {
[error]   X
[error]   lazy given val given_TC_X: X : TC
[error]  } does not have a symbol
[error] dotty.tools.dotc.typer.Namer.symbolOfTree(Namer.scala:105)
[error] dotty.tools.dotc.typer.Namer$TypeDefCompleter.completerTypeParams$$anonfun$1(Namer.scala:1037)
[error] scala.collection.immutable.List.map(List.scala:247)
[error] dotty.tools.dotc.typer.Namer$TypeDefCompleter.completerTypeParams(Namer.scala:1037)
[error] dotty.tools.dotc.typer.Namer$TypeDefCompleter.typeSig(Namer.scala:1044)
[error] dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:990)
[error] dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:859)
[error] dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:175)
[error] dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:190)
[error] dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:192)
[error] dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:393)
[error] dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:3447)
[error] dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3472)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3584)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3662)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3666)
[error] dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3688)
[error] dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3734)
[error] dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:3164)
[error] dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:3488)
[error] dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3492)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3584)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3662)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3666)
[error] dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3688)
[error] dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3734)
[error] dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:3297)
[error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3534)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3585)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3662)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3666)
[error] dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3777)
[error] dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$1(TyperPhase.scala:47)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] dotty.tools.dotc.core.Phases$Phase.monitor(Phases.scala:507)
[error] dotty.tools.dotc.typer.TyperPhase.typeCheck(TyperPhase.scala:53)
[error] dotty.tools.dotc.typer.TyperPhase.$anonfun$4(TyperPhase.scala:99)
[error] scala.collection.Iterator$$anon$6.hasNext(Iterator.scala:479)
[error] scala.collection.Iterator$$anon$9.hasNext(Iterator.scala:583)
[error] scala.collection.immutable.List.prependedAll(List.scala:152)
[error] scala.collection.immutable.List$.from(List.scala:685)
[error] scala.collection.immutable.List$.from(List.scala:682)
[error] scala.collection.IterableOps$WithFilter.map(Iterable.scala:900)
[error] dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:98)
[error] dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:343)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
[error] dotty.tools.dotc.Run.runPhases$1(Run.scala:336)
[error] dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:383)
[error] dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:395)
[error] dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69)
[error] dotty.tools.dotc.Run.compileUnits(Run.scala:395)
[error] dotty.tools.dotc.Run.compileSources(Run.scala:282)
[error] dotty.tools.dotc.Run.compile(Run.scala:267)
[error] dotty.tools.dotc.Driver.doCompile(Driver.scala:37)
[error] dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:141)
[error] dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
[error] sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:196)
[error] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error] sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:252)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:186)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:166)
[error] sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:241)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:166)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:214)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:542)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:542)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$3(Incremental.scala:182)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$3$adapted(Incremental.scala:180)
[error] sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:458)
[error] sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:117)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52)
[error] sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:263)
[error] sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:413)
[error] sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:500)
[error] sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:400)
[error] sbt.internal.inc.Incremental$.apply(Incremental.scala:208)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:542)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:496)
[error] sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:433)
[error] sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
[error] sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2443)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2393)
[error] sbt.internal.server.BspCompileTask$.$anonfun$compute$1(BspCompileTask.scala:41)
[error] sbt.internal.io.Retry$.apply(Retry.scala:47)
[error] sbt.internal.io.Retry$.apply(Retry.scala:29)
[error] sbt.internal.io.Retry$.apply(Retry.scala:24)
[error] sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:41)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2391)
[error] scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:63)
[error] sbt.std.Transform$$anon$4.work(Transform.scala:69)
[error] sbt.Execute.$anonfun$submit$2(Execute.scala:283)
[error] sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:24)
[error] sbt.Execute.work(Execute.scala:292)
[error] sbt.Execute.$anonfun$submit$1(Execute.scala:283)
[error] sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] sbt.CompletionService$$anon$2.call(CompletionService.scala:65)
[error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[error] java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[error] java.base/java.lang.Thread.run(Thread.java:829)
[error]
[error] stack trace is suppressed; run 'last Compile / compileIncremental' for the full output
[error] (Compile / compileIncremental) java.lang.IllegalArgumentException: Thicket {
[error]   X
[error]   lazy given val given_TC_X: X : TC
[error]  } does not have a symbol

Expected behavior

This should fail to compile (result in an error) but not crash.

@t9dupuy t9dupuy added itype:bug itype:crash stat:needs triage Every issue needs to have an "area" and "itype" label labels Feb 7, 2025
@KacperFKorban KacperFKorban added area:typer and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Feb 10, 2025
@mbovel
Copy link
Member

mbovel commented Feb 23, 2025

This issue was picked for the Scala Issue Spree of tomorrow, Monday, February 24th. @natsukagami and @jan-pieter will be working on it. If you have any insight into the issue or guidance on how to fix it, please leave it here.

@jan-pieter jan-pieter linked a pull request Feb 24, 2025 that will close this issue
@hamzaremmal hamzaremmal added the Spree Suitable for a future Spree label Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants