New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tailrec complains about suspended call #20012
Comments
That seems to behave as designed to me. Both |
There's always a recurrent danger of recursion. The suggestion is that it should warn for references I can do something about. But on the other ticket, I said it's a matter of expectations. |
While I do see a value in some sort of softer tail recursion check, I think a change here would be quite harmful to how a lot of things use this.
clearly in this case invoking the performance monitor breaks tail recursion, which we do need something to protect against. I think if we wanted to support something like this, it would need to be new functionality rather than an alteration to |
Maybe it needs For the scala 2 ticket, I added The concern is that "I need to write something reasonable, but then I can't use Another example is Note that tailrec requires an existing tail call, so the example of "I wrapped all my tail calls" would still error. I'll leave the ticket open for the suppressing annotation. |
Seems like the consensus is this works as intended. |
Compiler version
3.4.2
Minimized code
similarly or originally with by-name arguments:
or
Apologies for the extra import. If only it were not required.
Output
Expectation
Since the expression is just passing the lambda, it should not complain.
The "strict" behavior might be nice to have under a lint. "Leaking" a call in this way might be dangerous.
Alternative expectation is that you only use
@tailrec
when in peril of stack overflow, so you want maximum warnage; if you don't like that, leave it off.Reported as scala/bug#4649
The text was updated successfully, but these errors were encountered: