Skip to content

Conversation

@webwarrior-ws
Copy link
Contributor

Given that using the 'use' keyword on a non-IDisposable type would be flagged by the F# compiler as an (FS0193) error, we should assume that the type implements IDisposable when this keyword is present (because it's logical to assume that you run FSharpLint as an extra layer of correctness on top of compilation itself).

knocte and others added 3 commits December 22, 2025 09:16
Given that using the 'use' keyword on a non-IDisposable type
would be flagged by the F# compiler as an (FS0193) error,
we should assume that the type implements IDisposable when
this keyword is present (because it's logical to assume that
you run FSharpLint as an extra layer of correctness on top of
compilation itself).

Co-authored-by: webwarrior-ws <[email protected]>
If object is created using `new` keyword as a part of `use`
binding, don't apply the rule, because only types that
implement IDisposable can be used in `use` bindings.
Unlike with `use`, in case of `let` binding, usage of `new`
on unresolved type should fire the rule.
@knocte knocte merged commit 0b3c84a into fsprojects:master Dec 22, 2025
8 checks passed
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

Successfully merging this pull request may close these issues.

2 participants