From 296456a3c55f52c43e04d85825ab8eb336beea37 Mon Sep 17 00:00:00 2001 From: Copilot Date: Thu, 6 Aug 2026 04:22:19 +0200 Subject: [PATCH 1/3] Collapse OpenTypeDeclaration enforcement sites and drop dead mOpenDecl parameter The LanguageFeature.OpenTypeDeclaration flag is always-on for every supported --langversion (minimum 8.0, feature shipped in 5.0), so the gated branch is dead. Remove the flag checks at both enforcement sites and drop the now-unused mOpenDecl plumbing from TcOpenTypeDecl and TcOpenDecl and their call sites. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/Compiler/Checking/CheckDeclarations.fs | 20 +++++++++----------- src/Compiler/Checking/NameResolution.fs | 1 - 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index 1f2dfa3ec90..daf16806a83 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -782,11 +782,9 @@ let TcOpenModuleOrNamespaceDecl tcSink g amap scopem env (longId, m) = let env = OpenModuleOrNamespaceRefs tcSink g amap scopem false env modrefs openDecl env, [openDecl] -let TcOpenTypeDecl (cenv: cenv) mOpenDecl scopem env (synType: SynType, m) = +let TcOpenTypeDecl (cenv: cenv) scopem env (synType: SynType, m) = let g = cenv.g - checkLanguageFeatureAndRecover g.langVersion LanguageFeature.OpenTypeDeclaration mOpenDecl - let ty, _tpenv = TcType cenv NoNewTypars CheckCxs ItemOccurrence.Open WarnOnIWSAM.Yes env emptyUnscopedTyparEnv synType if not (isAppTy g ty) then @@ -799,14 +797,14 @@ let TcOpenTypeDecl (cenv: cenv) mOpenDecl scopem env (synType: SynType, m) = let env = OpenTypeContent cenv.tcSink g cenv.amap scopem env ty openDecl env, [openDecl] -let TcOpenDecl (cenv: cenv) mOpenDecl scopem env target = +let TcOpenDecl (cenv: cenv) scopem env target = let g = cenv.g match target with | SynOpenDeclTarget.ModuleOrNamespace (longId, m) -> TcOpenModuleOrNamespaceDecl cenv.tcSink g cenv.amap scopem env (longId.LongIdent, m) | SynOpenDeclTarget.Type (synType, m) -> - TcOpenTypeDecl cenv mOpenDecl scopem env (synType, m) + TcOpenTypeDecl cenv scopem env (synType, m) let MakeSafeInitField (cenv: cenv) env m isStatic = let id = @@ -1852,8 +1850,8 @@ module MutRecBindingChecking = // Process the 'open' declarations let envForDecls = - (envForDecls, opens) ||> List.fold (fun env (target, m, moduleRange, openDeclsRef) -> - let env, openDecls = TcOpenDecl cenv m moduleRange env target + (envForDecls, opens) ||> List.fold (fun env (target, _, moduleRange, openDeclsRef) -> + let env, openDecls = TcOpenDecl cenv moduleRange env target openDeclsRef.Value <- openDecls env) @@ -2824,8 +2822,8 @@ module EstablishTypeDefinitionCores = use _holder = TemporarilySuspendReportingTypecheckResultsToSink cenv.tcSink (env, shapes) ||> List.fold (fun env shape -> match shape with - | MutRecShape.Open(MutRecDataForOpen(SynOpenDeclTarget.ModuleOrNamespace _ as target, openm, moduleRange, _)) -> - let env, _ = TcOpenDecl cenv openm moduleRange env target + | MutRecShape.Open(MutRecDataForOpen(SynOpenDeclTarget.ModuleOrNamespace _ as target, _, moduleRange, _)) -> + let env, _ = TcOpenDecl cenv moduleRange env target env | _ -> env)) @@ -5261,7 +5259,7 @@ let rec TcSignatureElementNonMutRec (cenv: cenv) parent typeNames endm (env: TcE | SynModuleSigDecl.Open (target, m) -> let scopem = unionRanges m.EndRange endm - let env, _openDecl = TcOpenDecl cenv m scopem env target + let env, _openDecl = TcOpenDecl cenv scopem env target return env | SynModuleSigDecl.Val (vspec, m) -> @@ -5667,7 +5665,7 @@ let rec TcModuleOrNamespaceElementNonMutRec (cenv: cenv) parent typeNames scopem | SynModuleDecl.Open (target, m) -> let scopem = unionRanges m.EndRange scopem - let env, openDecls = TcOpenDecl cenv m scopem env target + let env, openDecls = TcOpenDecl cenv scopem env target let defns = match openDecls with | [] -> [] diff --git a/src/Compiler/Checking/NameResolution.fs b/src/Compiler/Checking/NameResolution.fs index ffb206076f6..92a3baf3ed1 100644 --- a/src/Compiler/Checking/NameResolution.fs +++ b/src/Compiler/Checking/NameResolution.fs @@ -1374,7 +1374,6 @@ and private AddStaticPartsOfTyconRefToNameEnv bulkAddMode ownDefinition g amap m eUnindexedExtensionMembers = eUnindexedExtensionMembers } and private CanAutoOpenTyconRef (g: TcGlobals) (tcref: TyconRef) = - g.langVersion.SupportsFeature LanguageFeature.OpenTypeDeclaration && not tcref.IsILTycon && EntityHasWellKnownAttribute g WellKnownEntityAttributes.AutoOpenAttribute tcref.Deref && tcref.Typars |> List.isEmpty From 2c0f64452093254f1f3dab200a04db1d06ba3181 Mon Sep 17 00:00:00 2001 From: Copilot Date: Thu, 6 Aug 2026 04:45:44 +0200 Subject: [PATCH 2/3] Remove OpenTypeDeclaration language feature flag definition Delete the always-on LanguageFeature.OpenTypeDeclaration DU case, its features-map entry, GetFeatureString arm, and the featureOpenTypeDeclaration FSComp.txt string. Regenerate xlf localization files via UpdateXlf. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/Compiler/FSComp.txt | 1 - src/Compiler/Facilities/LanguageFeatures.fs | 3 --- src/Compiler/Facilities/LanguageFeatures.fsi | 1 - src/Compiler/xlf/FSComp.txt.cs.xlf | 5 ----- src/Compiler/xlf/FSComp.txt.de.xlf | 5 ----- src/Compiler/xlf/FSComp.txt.es.xlf | 5 ----- src/Compiler/xlf/FSComp.txt.fr.xlf | 5 ----- src/Compiler/xlf/FSComp.txt.it.xlf | 5 ----- src/Compiler/xlf/FSComp.txt.ja.xlf | 5 ----- src/Compiler/xlf/FSComp.txt.ko.xlf | 5 ----- src/Compiler/xlf/FSComp.txt.pl.xlf | 5 ----- src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 5 ----- src/Compiler/xlf/FSComp.txt.ru.xlf | 5 ----- src/Compiler/xlf/FSComp.txt.tr.xlf | 5 ----- src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 5 ----- src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 5 ----- 16 files changed, 70 deletions(-) diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 26699fa4d9b..daad5eed2b4 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1568,7 +1568,6 @@ featureWildCardInForLoop,"wild card in for loop" featureRelaxWhitespace,"whitespace relaxation" featureNameOf,"nameof" featureImplicitYield,"implicit yield" -featureOpenTypeDeclaration,"open type declaration" featureDotlessFloat32Literal,"dotless float32 literal" featurePackageManagement,"package management" featureFromEndSlicing,"from-end slicing" diff --git a/src/Compiler/Facilities/LanguageFeatures.fs b/src/Compiler/Facilities/LanguageFeatures.fs index c7b75365c60..8c8029377d2 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fs +++ b/src/Compiler/Facilities/LanguageFeatures.fs @@ -22,7 +22,6 @@ type LanguageFeature = | RelaxWhitespace2 | NameOf | ImplicitYield - | OpenTypeDeclaration | DotlessFloat32Literal | PackageManagement | FromEndSlicing @@ -163,7 +162,6 @@ type LanguageVersion(versionText, ?disabledFeaturesArray: LanguageFeature array) LanguageFeature.AndBang, languageVersion50 LanguageFeature.NullableOptionalInterop, languageVersion50 LanguageFeature.DefaultInterfaceMemberConsumption, languageVersion50 - LanguageFeature.OpenTypeDeclaration, languageVersion50 LanguageFeature.PackageManagement, languageVersion50 LanguageFeature.WitnessPassing, languageVersion50 LanguageFeature.InterfacesWithMultipleGenericInstantiation, languageVersion50 @@ -369,7 +367,6 @@ type LanguageVersion(versionText, ?disabledFeaturesArray: LanguageFeature array) | LanguageFeature.RelaxWhitespace2 -> FSComp.SR.featureRelaxWhitespace2 () | LanguageFeature.NameOf -> FSComp.SR.featureNameOf () | LanguageFeature.ImplicitYield -> FSComp.SR.featureImplicitYield () - | LanguageFeature.OpenTypeDeclaration -> FSComp.SR.featureOpenTypeDeclaration () | LanguageFeature.DotlessFloat32Literal -> FSComp.SR.featureDotlessFloat32Literal () | LanguageFeature.PackageManagement -> FSComp.SR.featurePackageManagement () | LanguageFeature.FromEndSlicing -> FSComp.SR.featureFromEndSlicing () diff --git a/src/Compiler/Facilities/LanguageFeatures.fsi b/src/Compiler/Facilities/LanguageFeatures.fsi index 8c7ebd7e3c3..c96dd05c7c1 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fsi +++ b/src/Compiler/Facilities/LanguageFeatures.fsi @@ -12,7 +12,6 @@ type LanguageFeature = | RelaxWhitespace2 | NameOf | ImplicitYield - | OpenTypeDeclaration | DotlessFloat32Literal | PackageManagement | FromEndSlicing diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 8cb70b4c49e..86e044989a9 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -557,11 +557,6 @@ nullness checking - - open type declaration - Otevřít deklaraci typu - - overloads for custom operations přetížení pro vlastní operace diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 5686312be6b..175ed60826f 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -557,11 +557,6 @@ nullness checking - - open type declaration - Deklaration für offene Typen - - overloads for custom operations Überladungen für benutzerdefinierte Vorgänge diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index a3b4cfce50b..c4d74fc52c9 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -557,11 +557,6 @@ nullness checking - - open type declaration - declaración de tipo abierto - - overloads for custom operations sobrecargas para operaciones personalizadas diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index bf46f5ee12b..5b019836f1e 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -557,11 +557,6 @@ nullness checking - - open type declaration - déclaration de type ouverte - - overloads for custom operations surcharges pour les opérations personnalisées diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 6d705cdc2d1..bc7492c11d5 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -557,11 +557,6 @@ nullness checking - - open type declaration - dichiarazione di tipo aperto - - overloads for custom operations overload per le operazioni personalizzate diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 0b35b8e6dac..62633c96db8 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -557,11 +557,6 @@ nullness checking - - open type declaration - オープン型宣言 - - overloads for custom operations カスタム操作のオーバーロード diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index b00f54bfa76..dc2fdf273d0 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -557,11 +557,6 @@ nullness checking - - open type declaration - 개방형 형식 선언 - - overloads for custom operations 사용자 지정 작업의 오버로드 diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index b6d4b78a2d8..d1e60095cec 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -557,11 +557,6 @@ nullness checking - - open type declaration - deklaracja typu otwartego - - overloads for custom operations przeciążenia dla operacji niestandardowych diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index ba46752a529..c0692a1d18a 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -557,11 +557,6 @@ nullness checking - - open type declaration - declaração de tipo aberto - - overloads for custom operations sobrecargas para operações personalizadas diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 4a13225bc33..a49634263b3 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -557,11 +557,6 @@ nullness checking - - open type declaration - объявление открытого типа - - overloads for custom operations перегрузки для настраиваемых операций diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 0d880a3f23a..eaa3a699d28 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -557,11 +557,6 @@ nullness checking - - open type declaration - açık tür bildirimi - - overloads for custom operations özel işlemler için aşırı yüklemeler diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index ce2c173e893..20d42bde8db 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -557,11 +557,6 @@ nullness checking - - open type declaration - 开放类型声明 - - overloads for custom operations 自定义操作的重载 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 09d5f37bea9..e49293574a2 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -557,11 +557,6 @@ nullness checking - - open type declaration - 開放式類型宣告 - - overloads for custom operations 為自訂作業多載 From 2f36d0d3815d456e8e97f5967337d134dfb13227 Mon Sep 17 00:00:00 2001 From: Copilot Date: Thu, 6 Aug 2026 08:12:06 +0200 Subject: [PATCH 3/3] Add release notes for OpenTypeDeclaration flag removal Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- docs/release-notes/.FSharp.Compiler.Service/11.0.100.md | 1 + docs/release-notes/.Language/preview.md | 1 + 2 files changed, 2 insertions(+) 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 0f816258bbf..b0d6f9ecdbf 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md +++ b/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md @@ -157,6 +157,7 @@ ### Changed +* Removed the always-on `OpenTypeDeclaration` language feature flag; `open type` declarations are unconditional and `--disableLanguageFeature:OpenTypeDeclaration` is no longer a recognized feature name. ([Issue #20148](https://github.com/dotnet/fsharp/issues/20148), [PR #20215](https://github.com/dotnet/fsharp/pull/20215)) * Improvements in error and warning messages: new error FS3885 when `let!`/`use!` is the final expression in a computation expression; new warning FS3886 when a list literal contains a single tuple element (likely missing `;` separator); improved wording for FS0003, FS0025, FS0039, FS0072, FS0247, FS0597, FS0670, FS3082, and SRTP operator-not-in-scope hints. ([PR #19398](https://github.com/dotnet/fsharp/pull/19398)) * Exception field serialization (`GetObjectData` and field-restoring constructor) is now gated behind `langversion:11` (`LanguageFeature.ExceptionFieldSerializationSupport`). With langversion ≤10, exception codegen is unchanged from pre-#19342 behavior. ([PR #19746](https://github.com/dotnet/fsharp/pull/19746)) * Lower string-typed interpolated strings to `System.String.Concat` rather than the reflection-based `printf` engine, making them trim- and NativeAOT-compatible. This generalizes and ungates the previous all-string `String.Concat` optimization, so it now applies to every string-typed interpolation. ([Language suggestion #1108](https://github.com/fsharp/fslang-suggestions/issues/1108), [PR #19971](https://github.com/dotnet/fsharp/pull/19971)) diff --git a/docs/release-notes/.Language/preview.md b/docs/release-notes/.Language/preview.md index 30df5427619..36305336657 100644 --- a/docs/release-notes/.Language/preview.md +++ b/docs/release-notes/.Language/preview.md @@ -12,6 +12,7 @@ ### Changed +* Removed the always-on `OpenTypeDeclaration` language feature flag; `open type` declarations are unconditional and `--disableLanguageFeature:OpenTypeDeclaration` is no longer a recognized feature name. ([Issue #20148](https://github.com/dotnet/fsharp/issues/20148), [PR #20215](https://github.com/dotnet/fsharp/pull/20215)) * Direct delegate construction ([PR #19993](https://github.com/dotnet/fsharp/pull/19993)) * A delegate built from a method or function now points straight at that method instead of an intermediate closure, so `delegate.Method` is the real target and no closure class is generated. * Two delegates built from the same method and target now compare equal, where the previous closure form produced distinct instances; this also makes `Delegate.Remove` (and `-=` on events) match and remove such a delegate that it previously left in place.