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

Try to warn on Resource leak #76

Open
BalmungSan opened this issue Dec 20, 2022 · 1 comment
Open

Try to warn on Resource leak #76

BalmungSan opened this issue Dec 20, 2022 · 1 comment

Comments

@BalmungSan
Copy link

Since I don't know much about scalafix not sure how hard, or even impossible, this will be...
But, it would be great to warn / error if someone tries to leak a Resource using pure or delay inside use; which is a somewhat common beginner mistake.

Maybe a best effort that tries to catch common variations like ra.use(a => a.pure[F]) or ra.use(IO.apply) can be enough?
Another idea would be to warn if use returns an F[A] rather than some F[B] (meaning the same type of the Resource), since on the surface it seems that would never be a good idea; but I may be being too naive.

@armanbilge
Copy link
Member

Another idea would be to warn if use returns an F[A] rather than some F[B] (meaning the same type of the Resource)

FWIW I really like this idea. Whereas a "pure" based fix can probably be implemented as a syntactic rule, inspecting the inferred types will require a semantic rule.

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

2 participants