From 581eb587853386dfae144cf323e65ea8cd8334ec Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 10 Apr 2026 09:47:04 +0000 Subject: [PATCH 1/3] Initial plan From b2af65df49950ccffc50e878bd41d4f542cb1ed8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 10 Apr 2026 10:03:04 +0000 Subject: [PATCH 2/3] Fix ICE in BuildDisposableCleanup when Dispose extension methods are in scope Use AtMostOneResult to leverage existing intrinsic-over-extension priority in AllMethInfosOfTypeInScope, matching how regular method calls resolve Dispose. Agent-Logs-Url: https://github.com/dotnet/fsharp/sessions/ebba43f1-81b6-417c-9138-f5867056fd94 Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com> --- .../Checking/Expressions/CheckExpressions.fs | 2 +- .../UseBindings/UseBindings.fs | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fs b/src/Compiler/Checking/Expressions/CheckExpressions.fs index 635a0dff045..fcc561c0fff 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fs @@ -3149,7 +3149,7 @@ let BuildDisposableCleanup (cenv: cenv) env m (v: Val) = v.SetHasBeenReferenced() let disposeMethod = - match TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AllResults cenv env m ad "Dispose" g.system_IDisposable_ty with + match TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AtMostOneResult cenv env m ad "Dispose" g.system_IDisposable_ty with | [x] -> x | _ -> error(InternalError(FSComp.SR.tcCouldNotFindIDisposable(), m)) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/UseBindings/UseBindings.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/UseBindings/UseBindings.fs index 6b042ea93bf..7ccea723a8f 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/UseBindings/UseBindings.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/UseBindings/UseBindings.fs @@ -45,3 +45,29 @@ module UseBindings = |> asFsx |> compile |> shouldSucceed + + [] + let ``use binding does not ICE when Dispose extension method is in scope`` () = + FSharp """ +open System +open System.Runtime.CompilerServices + +type Disposable() = + interface IDisposable with + member _.Dispose() = () + +[] +type PublicExtensions = + [] + static member inline Dispose(this: #IDisposable) = + this + +let foo() = + use a = new Disposable() + () + +foo() + """ + |> asExe + |> compile + |> shouldSucceed From c44e99a236b29f430e051b9708848955bda8694f Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Tue, 21 Apr 2026 09:56:45 +0200 Subject: [PATCH 3/3] Add release notes for PR #19568 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- docs/release-notes/.FSharp.Compiler.Service/11.0.100.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md b/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md index 6cc50c2822e..7ef0de76012 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md +++ b/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md @@ -34,6 +34,7 @@ * Fix signature generation: backtick escaping for identifiers containing backticks. ([Issue #15389](https://github.com/dotnet/fsharp/issues/15389), [PR #19586](https://github.com/dotnet/fsharp/pull/19586)) * Fix signature generation: `private` keyword placement for prefix-style type abbreviations. ([Issue #15560](https://github.com/dotnet/fsharp/issues/15560), [PR #19586](https://github.com/dotnet/fsharp/pull/19586)) * Fix signature generation: missing `[]` attribute for types without visible constructors. ([Issue #16531](https://github.com/dotnet/fsharp/issues/16531), [PR #19586](https://github.com/dotnet/fsharp/pull/19586)) +* Fix internal compiler error in `use` bindings when a C#-style `Dispose` extension method is in scope alongside `IDisposable.Dispose`. ([Issue #19552](https://github.com/dotnet/fsharp/issues/19552), [PR #19568](https://github.com/dotnet/fsharp/pull/19568)) ### Added