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

Suggest return raise fooException or return failwith instead of raise/failwith when inside async block #597

Closed
knocte opened this issue Feb 5, 2023 · 1 comment · Fixed by #623

Comments

@knocte
Copy link
Collaborator

knocte commented Feb 5, 2023

If a raise or failwith is placed inside an async{} block without a return before it, then the F# compiler will demand that you return a proper value (in case function returns Async<'T> where 'T is different than unit). Because of that, the developer might add by mistake code that is actually unreachable without her realizing it.

@knocte
Copy link
Collaborator Author

knocte commented Feb 5, 2023

Mmm, unfortunately, even with a return keyword, the possible subsequent LOC after it that has another return keyword might still not be flagged as unreachable by F# compiler (TODO: file bug?). So the idea here would be that this rule detects both the absence of return keyword and/or unreachable code after it.

knocte added a commit that referenced this issue Dec 7, 2023
Rule that warns about forgetting "return" keyword when raising exceptions in async blocks.

Fixes #597
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant