So I have the following code (doing exercise 4 of that tutorial):
import scala.util.continuations._
object Main {
def times(lst: List[Int]): Int@cps[Int] = lst match {
case Nil => 1
case 0 :: rest => shift{(_: Int=>Int) => 0 } * times(rest)
case first :: rest => first * times(rest)
}
def main(args: Array[String]) {
println(reset{times(List(0 to 1000: _*))})
}
}
I'm compiling with scala 2.10.0 and I got the following warning:
CWSO.scala:3: warning: expression matchEnd9(x: Int){
x
} is cps-transformed unexpectedly
def times(lst: List[Int]): Int@cps[Int] = lst match {
^
one warning found
Is there something wrong in the way I wrote that code? What should I do to avoid the warning? The code seems to be doing the correct thing (multiplies numbers and aborts early when 0 is the first element).
This smells like a bug, and was reported as such: https://issues.scala-lang.org/browse/SI-6817