Regression In `scalalandio/chimney` - Missing Span
Introduction
In this article, we will be discussing a regression issue in the scalalandio/chimney
library. The issue is related to a missing span in the compiler, which is causing a java.lang.AssertionError
to be thrown. We will go through the details of the issue, the stacktrace, and the possible causes.
Compiler Version
The last good revision of the compiler was 3.7.1-RC1-bin-20250411-f4847cc-NIGHTLY
, while the first bad revision was 3.7.1-RC1-bin-20250412-e70ea84-NIGHTLY
. The bisect points to either d72e5eaa65c077a9bdfd4cf7f587e9ea0499f664
or 19dcfa2ebb08ffd3e1b32d2cee4cc6c4a11539df
, but these two commits fail with different errors.
Not Yet Minimized
Unfortunately, the issue is not yet minimized, and I won't be able to provide a minimized version before April 28th.
Output
The output of the compiler is as follows:
Error: java.lang.AssertionError: assertion failed
Error: scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:11)
Error: dotty.tools.dotc.util.Spans$Span$.start$extension(Spans.scala:45)
Error: dotty.tools.dotc.typer.Migrations.implicitParams(Migrations.scala:137)
Error: dotty.tools.dotc.typer.Migrations.implicitParams$(Migrations.scala:28)
Error: dotty.tools.dotc.typer.Typer.implicitParams(Typer.scala:154)
Error: dotty.tools.dotc.typer.Typer.adaptToArgs$1(Typer.scala:4204)
....
Stacktrace
The full stacktrace is as follows:
[info]
[info] exception occurred while typechecking /build/repo/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/patcher/rules/PatchCollectionWithOptionCollectionRuleModule.scala
[info]
[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: /build/repo/chimney/src/main/scala/io/scalaland/chimney/internal/compiletime/derivation/patcher/rules/PatchCollectionWithOptionCollectionRuleModule.scala
[info] during phase: typer
[info] mode: Mode(ImplicitsEnabled)
[info] library version: version 2.13.16
[info] compiler version: version 3.7.1-RC1-bin-20250417-05b102a-NIGHTLY-git-05b102a
[info] settings: -Wconf List(msg=Unreachable case:s, msg=Missing symbol position:s, msg=can be rewritten automatically under:s) -Wnonunit-statement true -Wunused List(privates, locals, explicits, implicits, params) -Wvalue-discard true -Xcheck-macros true -Xkind-projector underscores -classpath /build/repo/chimney/target/jvm-3/classes:/build/repo/chimney-macro-commons/target/jvm-3/classes:/root/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.7.1-RC1-bin-20250417-05b102a-NIGHTLY/scala3-library_3-3.7.1-RC1-bin-20250417-05b102a-NIGHTLY.jar:/root/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/modules/scala-collection-compat_3/2.13.0/scala-collection-compat_3-2.13.0.jar:/root/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.16/scala-library-2.13.16.jar -d /build/repo/chimney/target/jvm-3/classes -explain true -explain-types true -no-indent true -rewrite Some(dotty.tools.dotc.rewrites.Rewrites@18e19f68) -source 3.3-migration
Error: ## Exception when compiling 140 sources to /build/repo/chimney/target/jvm-3/classes
Error: java.lang.AssertionError: assertion failed
Error: scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:11)
Error: dotty.tools.dotc.util.Spans$Span$.start$extension(Spans.scala:45)
Error: dotty.tools.dotc.typer.Migrations.implicitParams(Migrations.scala:137)
Error: dotty.tools.dotc.typer.Migrations.implicitParams$(Migrations.scala:28)
Error: dotty.tools.dotc.typer.Typer.implicitParams(Typer.scala:154)
Error: dotty.tools.dotc.typer.Typer.adaptToArgs$1(Typer.scala:4204)
Error: dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:4872)
Error: dotty.tools.dotc.typer.Typer.adapt(Typer.scala:4107)
Error: dotty.tools.dotc.typer.Typer.readapt$1(Typer.scala:4117)
Error: dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:4865)
Error: dotty.tools.dotc.typer.Typer.adapt(Typer.scala:4107)
Error: dotty.tools.dotc.typer.Typer.typed(Typer.scala:3727)
Error: dotty.tools.dotc.typer.Typer.typed(Typer.scala:3732)
Error: dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3843)
Error: dotty.tools.dotc.typer.Applications.tryWithProto$1(Applications.scala:1534)
Error: dotty.tools.dotc.typer.Applications.tryWithTypeArgs$1$anonfun$1(Applications.scala:1546)
Error: dotty.tools.dotc.typer.Typer$.tryEither(Typer.scala:127)
Error: dotty.tools.dotc.typer.Applications.tryWithTypeArgs$1(Applications.scala:1554)
Error: dotty.tools.dotc.typer.Applications.tryWithName$1(Applications.scala:1561)
Error: dotty.tools.dotc.typer.Applications.trySelectUnapply$1(Applications.scala:1575)
Error: dotty.tools.dotc.typer.Applications.typedUnApply(Applications.scala:1583)
Error: dotty.tools.dotc.typer.Applications.typedUnApply$(Applications.scala:465)
Error: dotty.tools.dotc.typer.Typer.typedUnApply(Typer.scala:154)
Error: dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3562)
Error: dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3650)
Error: dotty.tools.dotc.typer.Typer.typed(Typer.scala:3727)
Error: dotty.tools.dotc.typer.Typer.typed(Typer.scala:3732)
Error: dotty.tools.dotc.typer.Applications$UnapplyArgs.typedPatterns$anonfun$2(Applications.scala:289)
Error: scala.collection.LazyZip2$anon$1$anon$2.next(LazyZipOps.scala:42)
Error: scala.collection.immutable.List.prependedAll(List.scala:153)
Error: scala.collection.immutable.List$.from(List.scala:685)
Error: scala.collection.immutable.List$.from(List.scala:682)
Error: scala.collection.BuildFromLowPriority2$anon$11.fromSpecific(BuildFrom.scala:115)
Error: scala.collection.BuildFromLowPriority2$anon$11.fromSpecific(BuildFrom.scala:112)
Error: scala.collection.LazyZip2.map(LazyZipOps.scala:37)
Error: dotty.tools.dotc.typer.Applications$UnapplyArgs.typedPatterns(Applications.scala:289)
Error: dotty.tools.dotc.typer.Applications.typedUnApply(Applications.scala:1680)
Error: dotty.tools.dotc.typer.Applications.typedUnApply$(Applications.scala:465)
Error: dotty.tools.dotc.typer.Typer.typedUnApply(Typer.scala:154)
Error: dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3562)
Error: dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3650)
Error: dotty.tools.dotc.typer.Typer.typed(Typer.scala:3727)
Error: dotty.tools.dotc.typer.Typer.typed(Typer.scala:3732)
Error: dotty.tools.dotc.typer.Typer.typedTuple(Typer.scala:3461)
Error: dotty.tools.dotc.t<br/>
**Q&A: Regression in `scalalandio/chimney` - missing span**
=====================================================
**Q: What is the issue with the `scalalandio/chimney` library?**
---------------------------------------------------------
A: The issue is related to a missing span in the compiler, which is causing a `java.lang.AssertionError` to be thrown.
**Q: What is a span in the compiler?**
--------------------------------------
A: A span in the compiler refers to a range of characters in the source code that corresponds to a specific location in the abstract syntax tree (AST). It is used to provide information about the location of errors or warnings in the code.
**Q: What is the cause of the missing span?**
--------------------------------------------
A: The cause of the missing span is not yet known, but it is believed to be related to a change in the compiler that was introduced in the `3.7.1-RC1-bin-20250412-e70ea84-NIGHTLY` revision.
**Q: How can I reproduce the issue?**
--------------------------------------
A: Unfortunately, the issue is not yet minimized, and I won't be able to provide a minimized version before April 28th. However, you can try to reproduce the issue by compiling the `scalalandio/chimney` library with the `3.7.1-RC1-bin-20250412-e70ea84-NIGHTLY` revision.
**Q: What are the possible causes of the issue?**
------------------------------------------------
A: There are several possible causes of the issue, including:
* A bug in the compiler that was introduced in the `3.7.1-RC1-bin-20250412-e70ea84-NIGHTLY` revision.
* A change in the `scalalandio/chimney` library that is causing the compiler to fail.
* A conflict between the `scalalandio/chimney` library and another library that is being used.
**Q: How can I fix the issue?**
------------------------------
A: Unfortunately, the issue is not yet fixed, and it will require further investigation to determine the cause and fix the problem.
**Q: Where can I find more information about the issue?**
------------------------------------------------------
A: You can find more information about the issue on the `scalalandio/chimney` GitHub page, as well as on the Scala mailing list.
**Q: How can I help with the investigation?**
------------------------------------------------
A: If you are interested in helping with the investigation, you can try to reproduce the issue and provide more information about the error message you are seeing. You can also try to provide a minimized version of the code that is causing the issue.
**Q: What is the expected resolution of the issue?**
------------------------------------------------
A: The expected resolution of the issue is to fix the bug in the compiler that is causing the missing span. This may involve updating the compiler to a newer version or fixing the bug in the `scalalandio/chimney` library.
**Q: When can I expect the issue to be fixed?**
------------------------------------------------
A: Unfortunately, it is difficult to predict when the issue will be fixed. It will depend on the complexity of the issue and the availability of resources to fix it. However, we will do our best to provide an update as soon as possible.