Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Bugfix :: Support for 'use' on a nullable IDisposable #18262

Merged
merged 3 commits into from
Feb 3, 2025

Conversation

T-Gro
Copy link
Member

@T-Gro T-Gro commented Jan 23, 2025

Codegen for use does emit a defensive null check for the resource, therefore the argument to use can be anything which can subsume to IDisposable|null, and does not have to strictly enforce an IDisposable.

// Should work without warnings
let workWithResource (getD:int -> (IDisposable|null)) =
    use _ = getD 15
    15

Copy link
Contributor

github-actions bot commented Jan 23, 2025

❗ Release notes required


✅ Found changes and release notes in following paths:

Change path Release notes path Description
src/Compiler docs/release-notes/.FSharp.Compiler.Service/9.0.300.md

@T-Gro T-Gro marked this pull request as ready for review February 3, 2025 11:06
@T-Gro T-Gro requested a review from a team as a code owner February 3, 2025 11:06
@psfinaki psfinaki merged commit 3195041 into main Feb 3, 2025
33 checks passed
@T-Gro T-Gro deleted the bugfix/allow-use-on-nullable-disposable branch February 4, 2025 13:03
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants