Skip to content
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

Potential StackOverflowError in mapK of RebalanceCallback #130

Closed
nikitapecasa opened this issue Apr 13, 2021 · 1 comment
Closed

Potential StackOverflowError in mapK of RebalanceCallback #130

nikitapecasa opened this issue Apr 13, 2021 · 1 comment

Comments

@nikitapecasa
Copy link
Contributor

@t3hnar says

I believe this may cause stackoverflow for huge enough data structure, however I don't think you should fix this.

def mapK[G[_]](fg: F ~> G): RebalanceCallback[G, A] = {
      self match {
        case Pure(a)          => Pure(a)
        case Bind(source, f)  => Bind(source.mapK(fg), f andThen (_.mapK(fg)))
@nikitapecasa
Copy link
Contributor Author

Fixed with

// lazy source is needed to avoid StackOverflowError in mapK implementation
   final case class Bind[F[_], S, +A](source: () => RebalanceCallback[F, S], fs: S => RebalanceCallback[F, A])
       extends RebalanceCallback[F, A]

in scope of #135
and there are tests proving that it's stack safe now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant