scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.89k stars 1.06k forks source link

Consistent compiler crash, assertion failed while typechecking #19317

Open jgogstad opened 11 months ago

jgogstad commented 11 months ago

Compiler version

3.3.1

Minimized code

Small project for reproducing: https://github.com/jgogstad/spire-scalac-crash,

There is a chance that Spire is a culprit here, however, there are no traces of Spire in the compiler stacktraces, hence filing the issue here. See repo linked above for contained test case.

import spire.math.{Bounded, IntegralOps}
import spire.implicits.*

extension [A: spire.math.Integral] (a: A) {
  def coerce: Long = implicitly[IntegralOps[A]].coerce(a)
}

// this code isn't actually correct as far as calculating sizes goes as it doesn't account for closed and open bounds
extension [A: spire.math.Integral] (n: Bounded[A]) {
  def size: Long = spire.math.Integral[A].minus(n.upperBound.a, n.lowerBound.a).coerce
}

Output (click arrow to expand)

```scala ❯ sbt compile [info] welcome to sbt 1.9.7 (Azul Systems, Inc. Java 11.0.10) [info] loading project definition from /Users/josteingogstad/source-code/github.com/jgogstad/spire-scalac-crash/project [info] loading settings for project spire-scalac-crash from build.sbt ... [info] set current project to hello-world (in build file:/Users/josteingogstad/source-code/github.com/jgogstad/spire-scalac-crash/) [info] Executing in batch mode. For better performance use sbt's shell [info] compiling 2 Scala sources to /Users/josteingogstad/source-code/github.com/jgogstad/spire-scalac-crash/target/scala-3.3.1/classes ... java.lang.AssertionError: assertion failed while typechecking /Users/josteingogstad/source-code/github.com/jgogstad/spire-scalac-crash/src/main/scala/SpireExtensions.scala [info] exception occurred while typechecking /Users/josteingogstad/source-code/github.com/jgogstad/spire-scalac-crash/src/main/scala/SpireExtensions.scala [info] [info] exception occurred while compiling List(/Users/josteingogstad/source-code/github.com/jgogstad/spire-scalac-crash/src/main/scala/Main.scala, /Users/josteingogstad/source-code/github.com/jgogstad/spire-scalac-crash/src/main/scala/SpireExtensions.scala) [info] [info] An unhandled exception was thrown in the compiler. [info] Please file a crash report here: [info] https://github.com/lampepfl/dotty/issues/new/choose [info] [info] while compiling: [info] during phase: [info] mode: Mode(ImplicitsEnabled) [info] library version: version 2.13.10 [info] compiler version: version 3.3.1 [info] settings: -bootclasspath /Users/josteingogstad/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.3.1/scala3-library_3-3.3.1.jar:/Users/josteingogstad/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.10/scala-library-2.13.10.jar -classpath /Users/josteingogstad/source-code/github.com/jgogstad/spire-scalac-crash/target/scala-3.3.1/classes:/Users/josteingogstad/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/typelevel/spire_3/0.18.0/spire_3-0.18.0.jar:/Users/josteingogstad/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/typelevel/spire-macros_3/0.18.0/spire-macros_3-0.18.0.jar:/Users/josteingogstad/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/typelevel/spire-platform_3/0.18.0/spire-platform_3-0.18.0.jar:/Users/josteingogstad/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/typelevel/spire-util_3/0.18.0/spire-util_3-0.18.0.jar:/Users/josteingogstad/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/typelevel/algebra_3/2.8.0/algebra_3-2.8.0.jar:/Users/josteingogstad/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/typelevel/cats-kernel_3/2.8.0/cats-kernel_3-2.8.0.jar -d /Users/josteingogstad/source-code/github.com/jgogstad/spire-scalac-crash/target/scala-3.3.1/classes [info] [info] tree: EmptyTree [info] tree position: : [info] tree type: [info] symbol: val [info] call site: package in module class [info] [info] == Source file context for tree position == [info] [error] ## Exception when compiling 2 sources to /Users/josteingogstad/source-code/github.com/jgogstad/spire-scalac-crash/target/scala-3.3.1/classes [error] java.lang.AssertionError: assertion failed [error] scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:11) [error] dotty.tools.dotc.ast.tpd$.TypeApply(tpd.scala:60) [error] dotty.tools.dotc.ast.tpd$TreeOps$.appliedToTypeTrees$extension(tpd.scala:985) [error] dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:4255) [error] dotty.tools.dotc.typer.Typer.adapt(Typer.scala:3587) [error] dotty.tools.dotc.typer.ProtoTypes$FunProto.typedArg(ProtoTypes.scala:497) [error] dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:897) [error] dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:897) [error] dotty.tools.dotc.typer.Applications$Application.addTyped$1(Applications.scala:589) [error] dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:653) [error] dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:492) [error] dotty.tools.dotc.typer.Applications$TypedApply.(Applications.scala:779) [error] dotty.tools.dotc.typer.Applications$ApplyToUntyped.(Applications.scala:896) [error] dotty.tools.dotc.typer.Applications.ApplyTo(Applications.scala:1126) [error] dotty.tools.dotc.typer.Applications.ApplyTo$(Applications.scala:352) [error] dotty.tools.dotc.typer.Typer.ApplyTo(Typer.scala:116) [error] dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:969) [error] dotty.tools.dotc.typer.Applications.realApply$1$$anonfun$2(Applications.scala:1052) [error] dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:3324) [error] dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:1063) [error] dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1101) [error] dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:352) [error] dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:116) [error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3048) [error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3112) [error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3184) [error] dotty.tools.dotc.typer.Implicits.tryConversion$1(Implicits.scala:1136) [error] dotty.tools.dotc.typer.Implicits.typedImplicit(Implicits.scala:1167) [error] dotty.tools.dotc.typer.Implicits.typedImplicit$(Implicits.scala:818) [error] dotty.tools.dotc.typer.Typer.typedImplicit(Typer.scala:116) [error] dotty.tools.dotc.typer.Implicits$ImplicitSearch.tryImplicit(Implicits.scala:1242) [error] dotty.tools.dotc.typer.Implicits$ImplicitSearch.rank$1(Implicits.scala:1341) [error] dotty.tools.dotc.typer.Implicits$ImplicitSearch.searchImplicit(Implicits.scala:1511) [error] dotty.tools.dotc.typer.Implicits$ImplicitSearch.searchImplicit(Implicits.scala:1539) [error] dotty.tools.dotc.typer.Implicits$ImplicitSearch.bestImplicit(Implicits.scala:1572) [error] dotty.tools.dotc.typer.Implicits.inferImplicit(Implicits.scala:1060) [error] dotty.tools.dotc.typer.Implicits.inferImplicit$(Implicits.scala:818) [error] dotty.tools.dotc.typer.Typer.inferImplicit(Typer.scala:116) [error] dotty.tools.dotc.typer.Implicits.inferView(Implicits.scala:856) [error] dotty.tools.dotc.typer.Implicits.inferView$(Implicits.scala:818) [error] dotty.tools.dotc.typer.Typer.inferView(Typer.scala:116) [error] dotty.tools.dotc.typer.Implicits.viewExists(Implicits.scala:831) [error] dotty.tools.dotc.typer.Implicits.viewExists$(Implicits.scala:818) [error] dotty.tools.dotc.typer.Typer.viewExists(Typer.scala:116) [error] dotty.tools.dotc.typer.Implicits.ignoredConvertibleImplicits$1$$anonfun$3(Implicits.scala:960) [error] scala.collection.Iterator$$anon$6.hasNext(Iterator.scala:479) [error] scala.collection.Iterator.isEmpty(Iterator.scala:466) [error] scala.collection.Iterator.isEmpty$(Iterator.scala:466) [error] scala.collection.AbstractIterator.isEmpty(Iterator.scala:1300) [error] scala.collection.View$Filter.isEmpty(View.scala:146) [error] scala.collection.IterableOnceOps.nonEmpty(IterableOnce.scala:833) [error] scala.collection.IterableOnceOps.nonEmpty$(IterableOnce.scala:833) [error] scala.collection.AbstractIterable.nonEmpty(Iterable.scala:933) [error] dotty.tools.dotc.reporting.MissingImplicitArgument.noChainConversionsNote$1(messages.scala:2838) [error] dotty.tools.dotc.reporting.MissingImplicitArgument.msgPostscript$$anonfun$4(messages.scala:2846) [error] scala.Option.orElse(Option.scala:477) [error] dotty.tools.dotc.reporting.MissingImplicitArgument.msgPostscript(messages.scala:2846) [error] dotty.tools.dotc.reporting.Message.message$$anonfun$1(Message.scala:345) [error] dotty.tools.dotc.reporting.Message.inMessageContext(Message.scala:341) [error] dotty.tools.dotc.reporting.Message.message(Message.scala:345) [error] dotty.tools.dotc.reporting.Message.isNonSensical(Message.scala:322) [error] dotty.tools.dotc.reporting.HideNonSensicalMessages.isHidden(HideNonSensicalMessages.scala:16) [error] dotty.tools.dotc.reporting.HideNonSensicalMessages.isHidden$(HideNonSensicalMessages.scala:10) [error] dotty.tools.dotc.reporting.AbstractReporter.isHidden(AbstractReporter.scala:8) [error] dotty.tools.dotc.reporting.Reporter.issueUnconfigured(Reporter.scala:156) [error] dotty.tools.dotc.reporting.Reporter.go$1(Reporter.scala:181) [error] dotty.tools.dotc.reporting.Reporter.issueIfNotSuppressed(Reporter.scala:200) [error] dotty.tools.dotc.reporting.Reporter.report(Reporter.scala:203) [error] dotty.tools.dotc.report$.error(report.scala:68) [error] dotty.tools.dotc.typer.Typer.issueErrors$1$$anonfun$1(Typer.scala:3808) [error] scala.runtime.function.JProcedure3.apply(JProcedure3.java:15) [error] scala.runtime.function.JProcedure3.apply(JProcedure3.java:10) [error] scala.collection.LazyZip3.foreach(LazyZipOps.scala:248) [error] dotty.tools.dotc.typer.Typer.issueErrors$1(Typer.scala:3810) [error] dotty.tools.dotc.typer.Typer.addImplicitArgs$1(Typer.scala:3832) [error] dotty.tools.dotc.typer.Typer.adaptNoArgsImplicitMethod$1(Typer.scala:3849) [error] dotty.tools.dotc.typer.Typer.adaptNoArgs$1(Typer.scala:4038) [error] dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:4268) [error] dotty.tools.dotc.typer.Typer.adapt(Typer.scala:3587) [error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3184) [error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3188) [error] dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3300) [error] dotty.tools.dotc.typer.Typer.typeSelectOnTerm$1(Typer.scala:752) [error] dotty.tools.dotc.typer.Typer.typedSelect(Typer.scala:790) [error] dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3017) [error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3111) [error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3184) [error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3188) [error] dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3300) [error] dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:941) [error] dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1101) [error] dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:352) [error] dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:116) [error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3048) [error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3112) [error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3184) [error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3188) [error] dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3300) [error] dotty.tools.dotc.typer.Typer.$anonfun$57(Typer.scala:2486) [error] dotty.tools.dotc.inlines.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:243) [error] dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:2486) [error] dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3024) [error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3111) [error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3184) [error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3188) [error] dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3210) [error] dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3256) [error] dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2669) [error] dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:3036) [error] dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3040) [error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3111) [error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3184) [error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3188) [error] dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3210) [error] dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3256) [error] dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2812) [error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3081) [error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3112) [error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3184) [error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3188) [error] dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3300) [error] dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$1(TyperPhase.scala:44) [error] dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$adapted$1(TyperPhase.scala:54) [error] scala.Function0.apply$mcV$sp(Function0.scala:42) [error] dotty.tools.dotc.core.Phases$Phase.monitor(Phases.scala:440) [error] dotty.tools.dotc.typer.TyperPhase.typeCheck(TyperPhase.scala:54) [error] dotty.tools.dotc.typer.TyperPhase.runOn$$anonfun$3(TyperPhase.scala:88) [error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15) [error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10) [error] scala.collection.immutable.List.foreach(List.scala:333) [error] dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:88) [error] dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:246) [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:1321) [error] dotty.tools.dotc.Run.runPhases$1(Run.scala:262) [error] dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:270) [error] dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:279) [error] dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67) [error] dotty.tools.dotc.Run.compileUnits(Run.scala:279) [error] dotty.tools.dotc.Run.compileSources(Run.scala:194) [error] dotty.tools.dotc.Run.compile(Run.scala:179) [error] dotty.tools.dotc.Driver.doCompile(Driver.scala:37) [error] dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:88) [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:193) [error] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23) [error] sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:248) [error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:183) [error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:163) [error] sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239) [error] sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:163) [error] sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:211) [error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:534) [error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:534) [error] sbt.internal.inc.Incremental$.$anonfun$apply$5(Incremental.scala:180) [error] sbt.internal.inc.Incremental$.$anonfun$apply$5$adapted(Incremental.scala:178) [error] sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:464) [error] sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116) [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:419) [error] sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:506) [error] sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:406) [error] sbt.internal.inc.Incremental$.apply(Incremental.scala:172) [error] sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:534) [error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:488) [error] sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332) [error] sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:425) [error] sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137) [error] sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2371) [error] sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2321) [error] sbt.internal.server.BspCompileTask$.$anonfun$compute$1(BspCompileTask.scala:31) [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:31) [error] sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2319) [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:834) [error] [error] java.lang.AssertionError: assertion failed [error] at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:11) [error] at dotty.tools.dotc.ast.tpd$.TypeApply(tpd.scala:60) [error] at dotty.tools.dotc.ast.tpd$TreeOps$.appliedToTypeTrees$extension(tpd.scala:985) [error] at dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:4255) [error] at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:3587) [error] at dotty.tools.dotc.typer.ProtoTypes$FunProto.typedArg(ProtoTypes.scala:497) [error] at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:897) [error] at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:897) [error] at dotty.tools.dotc.typer.Applications$Application.addTyped$1(Applications.scala:589) [error] at dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:653) [error] at dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:492) [error] at dotty.tools.dotc.typer.Applications$TypedApply.(Applications.scala:779) [error] at dotty.tools.dotc.typer.Applications$ApplyToUntyped.(Applications.scala:896) [error] at dotty.tools.dotc.typer.Applications.ApplyTo(Applications.scala:1126) [error] at dotty.tools.dotc.typer.Applications.ApplyTo$(Applications.scala:352) [error] at dotty.tools.dotc.typer.Typer.ApplyTo(Typer.scala:116) [error] at dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:969) [error] at dotty.tools.dotc.typer.Applications.realApply$1$$anonfun$2(Applications.scala:1052) [error] at dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:3324) [error] at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:1063) [error] at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1101) [error] at dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:352) [error] at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:116) [error] at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3048) [error] at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3112) [error] at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3184) [error] at dotty.tools.dotc.typer.Implicits.tryConversion$1(Implicits.scala:1136) [error] at dotty.tools.dotc.typer.Implicits.typedImplicit(Implicits.scala:1167) [error] at dotty.tools.dotc.typer.Implicits.typedImplicit$(Implicits.scala:818) [error] at dotty.tools.dotc.typer.Typer.typedImplicit(Typer.scala:116) [error] at dotty.tools.dotc.typer.Implicits$ImplicitSearch.tryImplicit(Implicits.scala:1242) [error] at dotty.tools.dotc.typer.Implicits$ImplicitSearch.rank$1(Implicits.scala:1341) [error] at dotty.tools.dotc.typer.Implicits$ImplicitSearch.searchImplicit(Implicits.scala:1511) [error] at dotty.tools.dotc.typer.Implicits$ImplicitSearch.searchImplicit(Implicits.scala:1539) [error] at dotty.tools.dotc.typer.Implicits$ImplicitSearch.bestImplicit(Implicits.scala:1572) [error] at dotty.tools.dotc.typer.Implicits.inferImplicit(Implicits.scala:1060) [error] at dotty.tools.dotc.typer.Implicits.inferImplicit$(Implicits.scala:818) [error] at dotty.tools.dotc.typer.Typer.inferImplicit(Typer.scala:116) [error] at dotty.tools.dotc.typer.Implicits.inferView(Implicits.scala:856) [error] at dotty.tools.dotc.typer.Implicits.inferView$(Implicits.scala:818) [error] at dotty.tools.dotc.typer.Typer.inferView(Typer.scala:116) [error] at dotty.tools.dotc.typer.Implicits.viewExists(Implicits.scala:831) [error] at dotty.tools.dotc.typer.Implicits.viewExists$(Implicits.scala:818) [error] at dotty.tools.dotc.typer.Typer.viewExists(Typer.scala:116) [error] at dotty.tools.dotc.typer.Implicits.ignoredConvertibleImplicits$1$$anonfun$3(Implicits.scala:960) [error] at scala.collection.Iterator$$anon$6.hasNext(Iterator.scala:479) [error] at scala.collection.Iterator.isEmpty(Iterator.scala:466) [error] at scala.collection.Iterator.isEmpty$(Iterator.scala:466) [error] at scala.collection.AbstractIterator.isEmpty(Iterator.scala:1300) [error] at scala.collection.View$Filter.isEmpty(View.scala:146) [error] at scala.collection.IterableOnceOps.nonEmpty(IterableOnce.scala:833) [error] at scala.collection.IterableOnceOps.nonEmpty$(IterableOnce.scala:833) [error] at scala.collection.AbstractIterable.nonEmpty(Iterable.scala:933) [error] at dotty.tools.dotc.reporting.MissingImplicitArgument.noChainConversionsNote$1(messages.scala:2838) [error] at dotty.tools.dotc.reporting.MissingImplicitArgument.msgPostscript$$anonfun$4(messages.scala:2846) [error] at scala.Option.orElse(Option.scala:477) [error] at dotty.tools.dotc.reporting.MissingImplicitArgument.msgPostscript(messages.scala:2846) [error] at dotty.tools.dotc.reporting.Message.message$$anonfun$1(Message.scala:345) [error] at dotty.tools.dotc.reporting.Message.inMessageContext(Message.scala:341) [error] at dotty.tools.dotc.reporting.Message.message(Message.scala:345) [error] at dotty.tools.dotc.reporting.Message.isNonSensical(Message.scala:322) [error] at dotty.tools.dotc.reporting.HideNonSensicalMessages.isHidden(HideNonSensicalMessages.scala:16) [error] at dotty.tools.dotc.reporting.HideNonSensicalMessages.isHidden$(HideNonSensicalMessages.scala:10) [error] at dotty.tools.dotc.reporting.AbstractReporter.isHidden(AbstractReporter.scala:8) [error] at dotty.tools.dotc.reporting.Reporter.issueUnconfigured(Reporter.scala:156) [error] at dotty.tools.dotc.reporting.Reporter.go$1(Reporter.scala:181) [error] at dotty.tools.dotc.reporting.Reporter.issueIfNotSuppressed(Reporter.scala:200) [error] at dotty.tools.dotc.reporting.Reporter.report(Reporter.scala:203) [error] at dotty.tools.dotc.report$.error(report.scala:68) [error] at dotty.tools.dotc.typer.Typer.issueErrors$1$$anonfun$1(Typer.scala:3808) [error] at scala.runtime.function.JProcedure3.apply(JProcedure3.java:15) [error] at scala.runtime.function.JProcedure3.apply(JProcedure3.java:10) [error] at scala.collection.LazyZip3.foreach(LazyZipOps.scala:248) [error] at dotty.tools.dotc.typer.Typer.issueErrors$1(Typer.scala:3810) [error] at dotty.tools.dotc.typer.Typer.addImplicitArgs$1(Typer.scala:3832) [error] at dotty.tools.dotc.typer.Typer.adaptNoArgsImplicitMethod$1(Typer.scala:3849) [error] at dotty.tools.dotc.typer.Typer.adaptNoArgs$1(Typer.scala:4038) [error] at dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:4268) [error] at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:3587) [error] at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3184) [error] at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3188) [error] at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3300) [error] at dotty.tools.dotc.typer.Typer.typeSelectOnTerm$1(Typer.scala:752) [error] at dotty.tools.dotc.typer.Typer.typedSelect(Typer.scala:790) [error] at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3017) [error] at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3111) [error] at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3184) [error] at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3188) [error] at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3300) [error] at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:941) [error] at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1101) [error] at dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:352) [error] at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:116) [error] at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3048) [error] at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3112) [error] at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3184) [error] at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3188) [error] at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3300) [error] at dotty.tools.dotc.typer.Typer.$anonfun$57(Typer.scala:2486) [error] at dotty.tools.dotc.inlines.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:243) [error] at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:2486) [error] at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3024) [error] at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3111) [error] at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3184) [error] at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3188) [error] at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3210) [error] at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3256) [error] at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2669) [error] at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:3036) [error] at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3040) [error] at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3111) [error] at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3184) [error] at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3188) [error] at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3210) [error] at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3256) [error] at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2812) [error] at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3081) [error] at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3112) [error] at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3184) [error] at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3188) [error] at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3300) [error] at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$1(TyperPhase.scala:44) [error] at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$adapted$1(TyperPhase.scala:54) [error] at scala.Function0.apply$mcV$sp(Function0.scala:42) [error] at dotty.tools.dotc.core.Phases$Phase.monitor(Phases.scala:440) [error] at dotty.tools.dotc.typer.TyperPhase.typeCheck(TyperPhase.scala:54) [error] at dotty.tools.dotc.typer.TyperPhase.runOn$$anonfun$3(TyperPhase.scala:88) [error] at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15) [error] at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10) [error] at scala.collection.immutable.List.foreach(List.scala:333) [error] at dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:88) [error] at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:246) [error] at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15) [error] at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10) [error] at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1321) [error] at dotty.tools.dotc.Run.runPhases$1(Run.scala:262) [error] at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:270) [error] at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:279) [error] at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67) [error] at dotty.tools.dotc.Run.compileUnits(Run.scala:279) [error] at dotty.tools.dotc.Run.compileSources(Run.scala:194) [error] at dotty.tools.dotc.Run.compile(Run.scala:179) [error] at dotty.tools.dotc.Driver.doCompile(Driver.scala:37) [error] at dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:88) [error] at dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22) [error] at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91) [error] at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:193) [error] at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23) [error] at sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:248) [error] at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:183) [error] at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:163) [error] at sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239) [error] at sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:163) [error] at sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:211) [error] at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:534) [error] at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:534) [error] at sbt.internal.inc.Incremental$.$anonfun$apply$5(Incremental.scala:180) [error] at sbt.internal.inc.Incremental$.$anonfun$apply$5$adapted(Incremental.scala:178) [error] at sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:464) [error] at sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116) [error] at sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56) [error] at sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52) [error] at sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:263) [error] at sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:419) [error] at sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:506) [error] at sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:406) [error] at sbt.internal.inc.Incremental$.apply(Incremental.scala:172) [error] at sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:534) [error] at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:488) [error] at sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332) [error] at sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:425) [error] at sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137) [error] at sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2371) [error] at sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2321) [error] at sbt.internal.server.BspCompileTask$.$anonfun$compute$1(BspCompileTask.scala:31) [error] at sbt.internal.io.Retry$.apply(Retry.scala:47) [error] at sbt.internal.io.Retry$.apply(Retry.scala:29) [error] at sbt.internal.io.Retry$.apply(Retry.scala:24) [error] at sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:31) [error] at sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2319) [error] at scala.Function1.$anonfun$compose$1(Function1.scala:49) [error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:63) [error] at sbt.std.Transform$$anon$4.work(Transform.scala:69) [error] at sbt.Execute.$anonfun$submit$2(Execute.scala:283) [error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:24) [error] at sbt.Execute.work(Execute.scala:292) [error] at sbt.Execute.$anonfun$submit$1(Execute.scala:283) [error] at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265) [error] at sbt.CompletionService$$anon$2.call(CompletionService.scala:65) [error] at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) [error] at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [error] at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) [error] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [error] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [error] at java.base/java.lang.Thread.run(Thread.java:834) [error] (Compile / compileIncremental) java.lang.AssertionError: assertion failed [error] Total time: 2 s, completed Dec 20, 2023, 8:23:32 PM ```
nicolasstucki commented 11 months ago

We should try to define the spire implicits and types in the example file to avoid the dependency.

nicolasstucki commented 11 months ago

@jgogstad could you compile it with the latest nightly build? That version should show more information on the assertion failure.

https://github.com/lampepfl/dotty/blob/d3fafd6ab11ce7385f31675a2ce7a305e3faf2a8/compiler/src/dotty/tools/dotc/ast/tpd.scala#L59

jgogstad commented 11 months ago

sure, code: https://github.com/jgogstad/spire-scalac-crash/tree/nightly

output

❯ sbt compile
[info] welcome to sbt 1.9.7 (Azul Systems, Inc. Java 11.0.10)
[info] loading project definition from /Users/josteingogstad/source-code/github.com/jgogstad/spire-scalac-crash/project
[info] loading settings for project spire-scalac-crash from build.sbt ...
[info] set current project to hello-world (in build file:/Users/josteingogstad/source-code/github.com/jgogstad/spire-scalac-crash/)
[info] Executing in batch mode. For better performance use sbt's shell
[info] compiling 2 Scala sources to /Users/josteingogstad/source-code/github.com/jgogstad/spire-scalac-crash/target/scala-3.4.0-RC1-bin-20231219-eae8831-NIGHTLY/classes ...
[error] -- [E172] Type Error: /Users/josteingogstad/source-code/github.com/jgogstad/spire-scalac-crash/src/main/scala/SpireExtensions.scala:5:47 
[error] 5 |  def coerce: Long = implicitly[IntegralOps[A]].coerce(a)
[error]   |                                               ^
[error]   |No given instance of type spire.math.IntegralOps[A] was found for parameter e of method implicitly in object Predef
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 8 s, completed Dec 21, 2023, 12:30:51 PM
nicolasstucki commented 11 months ago

At least the crash is fixed. It is hard to know if this is an expected error from this snipped of code alone. We will need a minimization.

We should also check if the crash fix will be in 3.3.2. If not, we should backport it.

MateuszKubuszok commented 11 months ago

Similar issue got reported in Chimney, but without a working reproduction. I also assumed it is a compiler bug, since I feel it's unlikely that 2 libraries have the same bug at the same time.

ldeluigi commented 9 months ago

I'm experiencing the same issue

cptwunderlich commented 9 months ago

I just got the same error in a project using FS2 and cats-effect.