We noticed some inconsistent behavior involving Double.NaN when enabling one the ZIO test suites on Dotty. The following snippet will print true and false on Dotty 0.20.0-RC1 whereas it will print false and false on Scala 2.13.1. I saw that there was another issue reported regarding Double.NaN in #6710 but it looks like that was resolved back in June so this appears to be different, though potentially related.
Please let me know if there is anything else I can do to help!
object Example extends App {
val a: Double = Double.NaN
val eval = (a <= 0) || (10L <= 0)
println(s"when Double.NaN is extracted to val, expression is evaluated to: $eval")
val eval2 = (Double.NaN <= 0) || (10L <= 0)
println(s"when Double.NaN is used directly, expression is evaluated to: $eval2")
}
I tracked this down to what looks like a bug in the backend. Dotty issues a dcmpl instruction where scalac issues a dcmpg. The eval2 case yields false in both compilers since it is constant folded.
I am not able to fix this right now. The plan is anyway to use the scalac backend in Dotty, which will hopefully fix this problem. /cc @lrytz
You are on fire!
Most helpful comment
I tracked this down to what looks like a bug in the backend. Dotty issues a
dcmplinstruction where scalac issues adcmpg. Theeval2case yieldsfalsein both compilers since it is constant folded.I am not able to fix this right now. The plan is anyway to use the scalac backend in Dotty, which will hopefully fix this problem. /cc @lrytz