-
Notifications
You must be signed in to change notification settings - Fork 67
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
Fix tailRecM being not stack safe #460
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your work on this! 🙏
Good to go when conflicts are resolved.
Looks like there are a lot of unrelated changes - or you based it off some old branch 🤔 |
Yeah I started my branch from the tag I rebased my branch to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! This will probably need porting across ZIO / CE versions and also to Managed
😄
Fixes #458.
Something to note is that the original implementation passes
tailRecMStackSafety
in cats (https://github.com/typelevel/cats/blob/e0784fc0d95b9c4eed0bb1ddce6c69e3fd9a4a4f/laws/src/main/scala/cats/laws/MonadLaws.scala#L39), which does not givetailRecM
a recursive function.This PR doesn't change the semantics in that case, but for the cases where
tailRecM
is given a recursive function like intailRecMConstructionStackSafety
, it prevents stack overflow during construction.It's tested on v2.5.1.0, so some changes may be necessary to apply this to master.