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
Compiling with 2.8.0.Beta1, if I use @scala.annotation.tailrec on a function that doesn't recurse, the compiler simply tells me that it cannot optimise it. It would be very useful if the compiler were able to tell me that this is because the function doesn't recurse.
The use case may sound silly - why annotate the function if it's not recursive? - but it has happened to me a few times where I have refactored a recursive function to no longer recurse, and then scratched my head for a while after getting the compile error.
The text was updated successfully, but these errors were encountered:
@paulp said:
I now have fancy detailed @tailrec messages implemented, but I'm putting the patch on ice until after this upcoming release-thing is rolled.
@paulp said:
(In r21599) Improved @tailrec error messages to specify the reason.
In the process fixed old bug involving tail call transformation.
Closes #3275, #2018. Review by dragos.
Dan Rosen (mergeconflict) said:
Reopening: when @tailrec is used on a non-recursive method, the default error message is still used: "it contains a recursive call not in tail position".
From TailCalls.scala:
elseif (!isRecursiveCall) {
if (receiverIsSuper) failHere("it contains a recursive call targetting a supertype")
else failHere(defaultReason)
}
I haven't done any scalac hacking, but I assume this is the spot where you'd want to say "method is non-recursive."
Compiling with 2.8.0.Beta1, if I use @scala.annotation.tailrec on a function that doesn't recurse, the compiler simply tells me that it cannot optimise it. It would be very useful if the compiler were able to tell me that this is because the function doesn't recurse.
The use case may sound silly - why annotate the function if it's not recursive? - but it has happened to me a few times where I have refactored a recursive function to no longer recurse, and then scratched my head for a while after getting the compile error.
The text was updated successfully, but these errors were encountered: