0.9.8→0.9.9 regression? but SSC(C)E triggers on earlier versions too
ScoreUnder opened this issue · 8 comments
I have a new build failure on my project which traces to an Update dotty-cps-async to 0.9.9
commit. I have tried to minimise the failing code to the shortest possible example, but after minimisation it seems to trigger the same problem in older versions too.
I will give the minimised example here:
import cps.*
import cps.monads.FutureAsyncMonad
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
class TestCase:
val objs = Seq(
new AnyRef:
def curry(v: Any)(w: Any): Unit = ()
def bad_func(): Future[Unit] =
async {
for message <- Nil.toSeq do
curry(Nil.toSeq)
()
}
)
This code has quickly turned into nonsense, but nonetheless it triggers the following failure:
java.lang.Exception: unexpected tree: closure($anonfun)
dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1271)
dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1071)
dotty.tools.dotc.transform.init.Semantic$Cache$Cache.assume(Semantic.scala:314)
dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1071)
dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1195)
dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1071)
dotty.tools.dotc.transform.init.Semantic$Cache$Cache.assume(Semantic.scala:314)
dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1071)
dotty.tools.dotc.transform.init.Semantic$.$anonfun$22(Semantic.scala:903)
dotty.tools.dotc.transform.init.Semantic$.promote(Semantic.scala:903)
dotty.tools.dotc.transform.init.Semantic$ArgInfo.promote(Semantic.scala:1051)
[...]
Some interesting things break this example and cause the code to compile properly again:
- Turning the
val
into adef
- Wrapping the
val
in a function - Not wrapping the object in a
Seq
- Using a sequence which isn't generated through a function call on another object (i.e.
Nil.toSeq
causes an error, butNil
itself doesn't cause the error. One could replace it with something likeSome(Seq(1, 2, 3)).get
and still encounter an error) - Moving the anonymous class to an outer class (but inner classes/objects still fail)
This appears to be a confluence of many factors, to a somewhat surprising degree of complexity.
The original project at the broken commit is here: https://github.com/ScoreUnder/canti-bot/tree/cb179d537c0494ddddb4dfd24904f75aae30611c
The offending function on which the example is based is here: https://github.com/ScoreUnder/canti-bot/blob/cb179d537c0494ddddb4dfd24904f75aae30611c/src/main/scala/score/discord/canti/functionality/Spoilers.scala#L74-L90
If you edit the build.sbt
in that project to lower the version of dotty-cps-async from 0.9.9
to 0.9.8
, it will compile properly again.
Thanks, reviewing.
What version of scala compiler do you use?
Looks like the bug is not triggered on the current snapshot with scala-3.1.3.
On the other side, I have made a few changes in the current snapshot, so it can be the result of those changes.
Can you look -- is this bug reproduced with the scala-3.1.3 compiler?
If yes -- I will release 0.9.10 with fix, if not - looks like this is a compiler bug that was fixed in 3.1.3
Hmm, reproduced in canti-bot project with scala 3.1.3
I found that it also requires -Ysafe-init
to trigger, which I did not notice because I was building under the same environment.
So, I am a little more suspicious that this might be a dotty bug, but I don't have the know-how to confirm that
Found the issue ;), its on my side.
preparing a next release, will write here, when it will be available.
0.9.10 is on maven central ;)
All good from my end, thank you!