fsprojects / fsprojects/FSharpLint
feat: Warn about possibly unreachable try-catch with Async jobs
Nobody has claimed this yet.
- Dominant language
- F#
- Stars
- 327
- Forks
- 74
- PR merge metrics
- No merged PRs in 30d
Description
Sometimes when we want to add a try-catch to a certain asynchronous function, we go from:
let Foo(): Async<'Bar> =
DoSomething()
to:
let Foo(): Async<'Bar> =
try
DoSomething()
with
| ex -> DoSomethingElse()
However, most of the time, the above change is wrong, because the exception only happens when the async job is running, not when the async job is being composed (as it's happening in the above). If we had added the try-with block inside an async{} block, this would have been fine.
Maybe we could create a rule that warns against this, and recommends converting 'Bar to Result<'Bar,'Err> instead.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No file, test, or entry point is named. Start by locating how FSharpLint defines and tests rules for F# async expressions, then determine how to distinguish try-with around async composition from handling inside async{}. Done means a warning and recommendation appear only for the unreachable pattern, with coverage for the valid form.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- fsharp
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100