-
Notifications
You must be signed in to change notification settings - Fork 155
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
nondeterministic compiler crash ¯\_(ツ)_/¯ #260
Comments
Oh dear! I haven't seen this one yet. Stack traces I've seen so far are #3 and scalacenter/scalafix#47. |
by calling `duplicate` before untypechecking the tree. This is an attempt to fix #260
@tpolecat I've just released refined 0.8.0 which contains a potential fix for these compiler crashes. If you see them again after the upgrade, please reopen this issue. |
Will do, still seeing it with 0.7. I'll let you know. Thanks! |
Sadly this is still happening. Only in 2.11, if that helps. It always compiles ok in 2.10 and 2.12. (I am unable to re-open.) |
Using refined's macro in doobies tests leads to nondeterministic compiler crashes (fthomas/refined#260). Fortunately these macros are not essential for testing doobie-refined, so I removed its usage from the tests.
I have started seeing this as well (refined 0.9.0). All I have been able to notice is that a slower build slave seems to run into this more often. But that may be purely coincidental. Sample stack trace
[error] java.lang.AssertionError: assertion failed: import failure: cannot determine unique overloaded method alternative from
[error] final package eu
[error] final package eu
[error] that matches package eu:eu.type
[error] at scala.reflect.internal.Importers$StandardImporter.disambiguate$1(Importers.scala:183)
[error] at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:188)
[error] at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:210)
[error] at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:169)
[error] at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:210)
[error] at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:166)
[error] at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:210)
[error] at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:166)
[error] at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:210)
[error] at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:166)
[error] at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:210)
[error] at scala.reflect.internal.Importers$StandardImporter.recreatedTreeCompleter(Importers.scala:298)
[error] at scala.reflect.internal.Importers$StandardImporter.$anonfun$importTree$1(Importers.scala:417)
[error] at scala.reflect.internal.Importers$StandardImporter.tryFixup(Importers.scala:49)
[error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:418)
[error] at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:383)
[error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:415)
[error] at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:383)
[error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:415)
[error] at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:367)
[error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:415)
[error] at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:370)
[error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:415)
[error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:29)
[error] at scala.reflect.macros.contexts.Evals.eval(Evals.scala:19)
[error] at scala.reflect.macros.contexts.Evals.eval$(Evals.scala:14)
[error] at scala.reflect.macros.contexts.Context.eval(Context.scala:6)
[error] at eu.timepit.refined.macros.MacroUtils.$anonfun$eval$1(MacroUtils.scala:24)
[error] at scala.Option.getOrElse(Option.scala:121)
[error] at eu.timepit.refined.macros.MacroUtils.tryN(MacroUtils.scala:28)
[error] at eu.timepit.refined.macros.MacroUtils.tryN$(MacroUtils.scala:27)
[error] at eu.timepit.refined.macros.RefineMacro.tryN(RefineMacro.scala:11)
[error] at eu.timepit.refined.macros.MacroUtils.eval(MacroUtils.scala:24)
[error] at eu.timepit.refined.macros.MacroUtils.eval$(MacroUtils.scala:17)
[error] at eu.timepit.refined.macros.RefineMacro.eval(RefineMacro.scala:11)
[error] at eu.timepit.refined.macros.RefineMacro.$anonfun$validateInstance$1(RefineMacro.scala:57)
[error] at scala.Option.getOrElse(Option.scala:121)
[error] at eu.timepit.refined.macros.RefineMacro.validateInstance(RefineMacro.scala:57)
[error] at eu.timepit.refined.macros.RefineMacro.impl(RefineMacro.scala:27)
[error] at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source)
[error] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] at java.lang.reflect.Method.invoke(Method.java:498)
[error] at scala.reflect.macros.runtime.JavaReflectionRuntimes$JavaReflectionResolvers.$anonfun$resolveJavaReflectionRuntime$4(JavaReflectionRuntimes.scala:34)
[error] at scala.tools.nsc.typechecker.Macros.macroExpandWithRuntime(Macros.scala:772)
|
@NeQuissimus Do you know the predicate for which the macro is called in this case? If it is provided by the library, we can fix this for this particular predicate by adding the appropriate |
@fthomas I had multiple of these, I can look them up tomorrow. |
Alright, so I had the following instances over the last couple of days:
None of these are built-in, I suppose :( |
@NeQuissimus They are not primitive predicates but composed of primitive predicates that are defined by the library so in principle we could add their |
I just received the same error compiling this exact file: It only uses |
I'm seeing this in the Scala community build at scala/community-build#1039 |
I've just read this comment by @retronym in scala/bug#9218 (comment): class Predicate[A, B] {
self => // self type needed to trigger the bug
} I think we can get rid of the self type in |
The self type is now gone in 0.9.12. If anyone observes this compiler crash with 0.9.12 or a newer version, please leave a comment here. |
Hey, just saw it again with |
Seeing this on 2.12.11, refined 0.9.12 |
I'm seeing the following error on Jenkins with Scala 2.13.1 and Refined 0.9.14:
I'm not able to reproduce it locally on sbt, so I'm not sure how to simplify the code much, but here a sample of where it seems to be choking: object InferenceType extends IntEnum[InferenceType[InferenceShape]] {
type Name = String Refined MatchesRegex[W.`"[a-z_0-9]+"`.T]
override val values: immutable.IndexedSeq[InferenceType[InferenceShape]] = findValues
private lazy val validValuesString: String = values.map(k => s"{name: '${k.name}', id: ${k.id}}").mkString(", ")
def withId(id: Int)(implicit pos: Position): InferenceType[InferenceShape] = withValueOpt(id).getOrElse {
// XXX This is where the compiler macro is choking...
// It seems to have trouble auto refining the string "id" for the LogView.withKey method
// TBD whether being inside string interpolation is the issue...
throw new NoSuchElementException(
s"Cannot find InferenceType with ${LogView.withKey("id", id)}, valid options are $validValuesString (${pos.show})"
)
}
// ...
}
object LogKey {
type Valid = MatchesRegex[W.`"[a-zA-Z_][a-zA-Z_0-9]+"`.T]
type Name = String Refined Valid
}
object LogView {
def withKey[V](
key: LogKey.Name,
value: V
)(implicit
format: LogFormat[V]
): String = {
s"${key.value}=${format.write(value)}"
}
// ...
} |
Ok, update... it works after moving the |
Another update: it is still broken 😢 Moving it out of the StringContext interpolation didn't help...
|
I was just getting something very similar to this with Scala 2.12.10 and refined 0.9.14 (previously 0.9.4). If I run |
I just got one of those. I'm running Scala 2.12.11, SBT 1.13.10 and refined 0.9.14
Right now I'm using just a single refined, this one:
|
Seeing this on:
On code like this:
Update: it actually only happens in bloop... |
@kubukoz Can you deterministically reproduce this with bloop? |
Not really deterministically, now everything is working fine... :( |
aaaaand I got it again, on a codebase that used to compile... is there some diagnostic I can take when this happens? Looks like I can refine things like |
That's because some refined/modules/core/shared/src/main/scala/eu/timepit/refined/macros/RefineMacro.scala Lines 40 to 89 in 4fa9cbc
For |
I've noticed this fail sporadically with |
I just saw this again, fwiw. Restarted sbt and it compiled fine. Confidence high! Maybe it will stop doing this in Scala 3 ;-) |
Yes, it won't happen with Scala 3 because that macro cannot be ported! :-) |
I am experiencing this same issue (Scala 2.13.7, jdk17) very randomly and rarely. Is there any other mitigation than compile twice? |
It seems that disabling parallel compilation might help, see scala/bug#10682 (comment) and gemini-hlsw/lucuma-core#449. The easier fix is to change compile-time checks of literals to runtime checks. This will also make it easier to port code to Scala 3, since the compile-time checks cannot be ported to Scala 3. |
Hello my team has encountered a lot flaky CI failure on GitHub action, scalac were failure with various and weird error. After a long search and isolating the first faulty commit. I found that removing all
Here some failure we got:
|
Ok my CI was also fix by:
So I think it's a scalac bug and not a refine bug. |
I saw this on Travis, compiling doobie at commit b2f02078d0162827b93a1d3408c2a9950ce477d4 under ++2.11.8. I restarted the build and it worked fine, so it's nondeterministic. I'm offering this on the chance that you will find it useful, but I don't expect a fix so feel free to close.
And again nearby.
The text was updated successfully, but these errors were encountered: