Closed lihaoyi closed 6 months ago
What's the stack trace of the error?
@sjrd at least as part of the Mill build, no stack trace is shown. Just the message above
I've minimized the code-under-compilation to much smaller repro:
package unroll
object Unrolled{
def foo(s: String, n: Int = 1, @Unroll b: Boolean = true) = s + n + b
}
This can be reproduced by checking out https://github.com/com-lihaoyi/unroll and running ./mill -i -j 5 -k "unroll[3.3.1].tests[objectMethod].v2.js.compile"
, printing
[#3]
[#3] unhandled exception while running genSJSIR on /Users/lihaoyi/Github/unroll/unroll/tests/objectMethod/v2/src/Unrolled.scala
[#3]
[#3] An unhandled exception was thrown in the compiler.
[#3] Please file a crash report here:
[#3] https://github.com/lampepfl/dotty/issues/new/choose
[#3]
[#3] while compiling: <no file>
[#3] during phase: <no phase>
[#3] mode: Mode(ImplicitsEnabled)
[#3] library version: version 2.13.10
[#3] compiler version: version 3.3.1
[#3] settings: -Vprint List(all) -Xplugin List(/Users/lihaoyi/Github/unroll/out/unroll/3.3.1/plugin/jar.dest/out.jar) -Xplugin-require List(unroll) -bootclasspath /Users/lihaoyi/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/lihaoyi/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_sjs1_3/3.3.1/scala3-library_sjs1_3-3.3.1.jar:/Users/lihaoyi/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-js/scalajs-library_2.13/1.13.1/scalajs-library_2.13-1.13.1.jar:/Users/lihaoyi/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/lihaoyi/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-js/scalajs-javalib/1.13.1/scalajs-javalib-1.13.1.jar:/Users/lihaoyi/Github/unroll/unroll/annotation/compile-resources:/Users/lihaoyi/Github/unroll/out/unroll/3.3.1/annotation/compile.dest/classes:/Users/lihaoyi/Github/unroll/unroll/tests/objectMethod/v2/compile-resources:/Users/lihaoyi/Github/unroll/out/unroll/3.3.1/tests/objectMethod/v2/js/compile.dest/classes -d /Users/lihaoyi/Github/unroll/out/unroll/3.3.1/tests/objectMethod/v2/js/compile.dest/classes -scalajs true
[#3]
[#3] tree: EmptyTree
[#3] tree position: :<unknown>
[#3] tree type: <notype>
[#3] symbol: val <none>
[#3] call site: package <root> in module class <root>
[#3]
[#3] == Source file context for tree position ==
[#3]
[#3]
[#3] [error] ## Exception when compiling 1 sources to /Users/lihaoyi/Github/unroll/out/unroll/3.3.1/tests/objectMethod/v2/js/compile.dest/classes
[#3] [error] dotty.tools.dotc.core.TypeError$$anon$1: Failure to disambiguate overloaded reference with
[#3] [error] method foo in object Unrolled: (x$0: String, x$1: Int): String and
[#3] [error] method foo in object Unrolled: (s: String, n: Int, b: Boolean): String
[#3] [error]
[#3] [error]
You can also run ./mill -i -j 5 -k "unroll[_].tests[_].__.run"
to run all the test cases, and show that only the unroll[3.3.1].tests[objectMethod].v2.js
and unroll[3.3.1].tests[objectMethod].v3.js
test cases fail (I haven't managed to come up with a repro for the other crasher in Scala-Native https://github.com/com-lihaoyi/unroll/issues/6)
-Xprint:all
shows the last phase before the crash looking like this
[#3] [info] [[syntax trees at end of MegaPhase{dropOuterAccessors, checkNoSuperThis, flatten, transformWildcards, moveStatic, expandPrivate, restoreScopes, selectStatic, junitBootstrappers, Collect entry points, collectSuperCalls, repeatableAnnotations}]] // /Users/lihaoyi/Github/unroll/unroll/tests/objectMethod/v2/src/Unrolled.scala
[#3] [info] package unroll {
[#3] [info] @SourceFile("unroll/tests/objectMethod/v2/src/Unrolled.scala") final module
[#3] [info] class Unrolled extends Object {
[#3] [info] def <init>(): Unit =
[#3] [info] {
[#3] [info] super()
[#3] [info] ()
[#3] [info] }
[#3] [info] private def writeReplace(): Object =
[#3] [info] new scala.runtime.ModuleSerializationProxy(classOf[unroll.Unrolled])
[#3] [info] def foo(s: String, n: Int, @Unroll b: Boolean): String =
[#3] [info] s.+(scala.Int.box(n)).+(scala.Boolean.box(b))
[#3] [info] def foo$default$2(): Int = 1
[#3] [info] def foo$default$3(): Boolean = true
[#3] [info] def foo(s: String, n: Int): String = this.foo(s, n, this.foo$default$3())
[#3] [info] }
[#3] [info] final lazy module val Unrolled: unroll.Unrolled = new unroll.Unrolled()
The error appears to be coming from https://github.com/lampepfl/dotty/blob/067ec20820943d61cf29733ea489e25bb920ea37/compiler/src/dotty/tools/dotc/core/Denotations.scala#L1267-L1277, though without a stack trace it's hard to tell how it got to that point
I think there's a debug flag to pass to the compiler to enable full stack traces.
-Ydebug-type-error
and -Ydebug-error
don't seem to give me any stack traces
I haven't managed to build a Dotty locally with additional logging; trying to run sbt publishLocal
from 3.3.2-RC3
and use the compiler jar gives me the following error
[error] java.lang.UnsupportedClassVersionError: dotty/tools/io/JDK9Reflectors has been compiled by a more recent version of the Java Runtime (class file version 65.0), this version of the Java Runtime only recognizes class file versions up to 61.0
Found it, just need to do defdef.symbol.flags &~ HasDefaultParams
on the new symbol. Apparently it's set separately and can get out of sync with the method parameter's default parameters
@sjrd for the record, I think the relevant callsite is this one
Presumably JSCodeGen.scala
is the only place in Dotty that checks whether or not multiple overloads have HasDefaultParams
set. I don't know how the other JVM/native backends check for such problematic overloads; maybe they inspect the default parameter trees/symbols instead?
I expect the JVM and Native backends don't need that information in the first place. We need it for the interpretability semantics with JavaScript.
Using the latest head version of Unroll in uPickle (https://github.com/com-lihaoyi/upickle/pull/555/files) gives me the error below. This only seems to happen in Scala-3.3.0/Scala.JS (3.3.1 gives same error)