You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ scala
Welcome to Scala 2.12.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_111).
Type in expressions for evaluation. Or try :help.
scala> import scala.annotation.tailrec
import scala.annotation.tailrec
scala> @tailrec private def loop[V](key: String): V = key match { case _ => loop[V](key) }
scala> @tailrec private def loop[V](key: String): V = key match { case _ => loop(key) }
<console>:12: error: could not optimize @tailrec annotated method loop: it contains a recursive call not in tail position
@tailrec private def loop[V](key: String): V = key match { case _ => loop(key) }
^
scala> @tailrec private def loop[V](key: String): V = loop(key)
<console>:12: error: could not optimize @tailrec annotated method loop: it is called recursively with different type arguments
@tailrec private def loop[V](key: String): V = loop(key)
^
You'd expect the last error message also for the first message.
With -Ydebug -Ylog:tailcalls:
[log tailcalls] Cannot rewrite recursive call at: source-<console>,line-12,offset=173 because: it is called recursively with different type arguments
[log tailcalls] Cannot rewrite recursive call at: source-<console>,line-12,offset=177 because: it contains a recursive call not in tail position
<console>:12: error: could not optimize @tailrec annotated method loop: it contains a recursive call not in tail position
@tailrec private def loop[V](key: String): V = key match { case _ => loop(key) }
^
On 2.13, note that with lots of debug output, we lose the source code to scrolling:
[log tailcalls] Cannot rewrite recursive call at: source-<console>,line-1,offset=69 because: it is called recursively with different type arguments
[log tailcalls] Cannot rewrite recursive call at: source-<console>,line-1,offset=73 because: it contains a recursive call not in tail position
^
error: could not optimize @tailrec annotated method loop: it contains a recursive call not in tail position
The text was updated successfully, but these errors were encountered:
As reported on SO:
You'd expect the last error message also for the first message.
With
-Ydebug -Ylog:tailcalls
:On 2.13, note that with lots of debug output, we lose the source code to scrolling:
The text was updated successfully, but these errors were encountered: