diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index b68c8046ce..ed4cafb0f1 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -62,6 +62,21 @@ Always run the core command. Always verify exit codes. No assumptions. ``` Non‑zero → classify & stop. +### CRITICAL TEST EXECUTION RULES +**ALWAYS** run tests before claiming success. **NEVER** mark work complete without verified passing tests. + +When running tests, **ALWAYS** report: +- Total number of tests executed +- Number passed / failed / skipped +- Execution duration +- Example: "Ran 5 tests: 5 passed, 0 failed, 0 skipped. Duration: 4.2 seconds" + +**ASSUME YOUR CODE IS THE PROBLEM**: When tests fail, ALWAYS assume your implementation is incorrect FIRST. Only after thorough investigation with evidence should you consider other causes like build issues or test infrastructure problems. + +**UNDERSTAND WHAT YOU'RE TESTING**: Before writing tests, understand exactly what behavior the feature controls. Research the codebase to see how the feature is actually used, not just how you think it should work. + +**TEST INCREMENTALLY**: After each code change, immediately run the relevant tests to verify the change works as expected. Don't accumulate multiple changes before testing. + ## 2. Bootstrap (Failure Detection Only) Two-phase build. No separate bootstrap command. Early proto/tool errors (e.g. "Error building tools") → `BootstrapFailure` (capture key lines). Stop. diff --git a/docs/release-notes/.Language/preview.md b/docs/release-notes/.Language/preview.md index bf4928cc21..af7584f7d6 100644 --- a/docs/release-notes/.Language/preview.md +++ b/docs/release-notes/.Language/preview.md @@ -11,6 +11,7 @@ * Allow `let!`, `use!`, `and!` type annotations without requiring parentheses (([PR #18508](https://github.com/dotnet/fsharp/pull/18508) and [PR #18682](https://github.com/dotnet/fsharp/pull/18682))) * Exception names are now validated for illegal characters using the same mechanism as types/modules/namespaces ([Issue #18763](https://github.com/dotnet/fsharp/issues/18763)) * Support tail calls in computation expressions ([PR #18804](https://github.com/dotnet/fsharp/pull/18804)) +* Add `--disableLanguageFeature` CLI switch and MSBuild property to selectively disable specific F# language features on a per-project basis. ([PR #TBD](https://github.com/dotnet/fsharp/pull/TBD)) ### Fixed diff --git a/src/Compiler/Driver/CompilerConfig.fs b/src/Compiler/Driver/CompilerConfig.fs index 53fdce6d9d..0fbe48fb2e 100644 --- a/src/Compiler/Driver/CompilerConfig.fs +++ b/src/Compiler/Driver/CompilerConfig.fs @@ -637,6 +637,8 @@ type TcConfigBuilder = mutable langVersion: LanguageVersion + mutable disabledLanguageFeatures: Set + mutable xmlDocInfoLoader: IXmlDocumentationInfoLoader option mutable exiter: Exiter @@ -827,6 +829,7 @@ type TcConfigBuilder = pathMap = PathMap.empty applyLineDirectives = true langVersion = LanguageVersion.Default + disabledLanguageFeatures = Set.empty implicitIncludeDir = implicitIncludeDir defaultFSharpBinariesDir = defaultFSharpBinariesDir reduceMemoryUsage = reduceMemoryUsage @@ -1402,6 +1405,7 @@ type TcConfig private (data: TcConfigBuilder, validate: bool) = member _.CloneToBuilder() = { data with conditionalDefines = data.conditionalDefines + disabledLanguageFeatures = data.disabledLanguageFeatures } member tcConfig.ComputeCanContainEntryPoint(sourceFiles: string list) = diff --git a/src/Compiler/Driver/CompilerConfig.fsi b/src/Compiler/Driver/CompilerConfig.fsi index de7fea398e..17e035109a 100644 --- a/src/Compiler/Driver/CompilerConfig.fsi +++ b/src/Compiler/Driver/CompilerConfig.fsi @@ -507,6 +507,8 @@ type TcConfigBuilder = mutable langVersion: LanguageVersion + mutable disabledLanguageFeatures: Set + mutable xmlDocInfoLoader: IXmlDocumentationInfoLoader option mutable exiter: Exiter diff --git a/src/Compiler/Driver/CompilerOptions.fs b/src/Compiler/Driver/CompilerOptions.fs index 0ab22de4f2..98cec17265 100644 --- a/src/Compiler/Driver/CompilerOptions.fs +++ b/src/Compiler/Driver/CompilerOptions.fs @@ -1168,11 +1168,28 @@ let languageFlags tcConfigB = CompilerOption( "langversion", tagLangVersionValues, - OptionString(fun switch -> tcConfigB.langVersion <- setLanguageVersion switch), + OptionString(fun switch -> + let newVersion = setLanguageVersion switch + // Preserve disabled features when updating version + tcConfigB.langVersion <- newVersion.WithDisabledFeatures(Set.toArray tcConfigB.disabledLanguageFeatures)), None, Some(FSComp.SR.optsSetLangVersion ()) ) + // -disableLanguageFeature: Disable a specific language feature by name (repeatable) + CompilerOption( + "disableLanguageFeature", + tagString, + OptionStringList(fun featureName -> + match LanguageVersion.TryParseFeature(featureName) with + | Some feature -> + tcConfigB.disabledLanguageFeatures <- Set.add feature tcConfigB.disabledLanguageFeatures + tcConfigB.langVersion <- tcConfigB.langVersion.WithDisabledFeatures(Set.toArray tcConfigB.disabledLanguageFeatures) + | None -> error (Error(FSComp.SR.optsUnrecognizedLanguageFeature featureName, rangeCmdArgs))), + None, + Some(FSComp.SR.optsDisableLanguageFeature ()) + ) + CompilerOption( "checked", tagNone, diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index ad6cd5f02a..f0e69c58ef 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1555,6 +1555,7 @@ optsCheckNulls,"Enable nullness declarations and checks (%s by default)" fSharpBannerVersion,"%s for F# %s" optsGetLangVersions,"Display the allowed values for language version." optsSetLangVersion,"Specify language version such as 'latest' or 'preview'." +optsDisableLanguageFeature,"Disable a specific language feature by name." optsSupportedLangVersions,"Supported language versions:" optsStrictIndentation,"Override indentation rules implied by the language version (%s by default)" nativeResourceFormatError,"Stream does not begin with a null resource and is not in '.RES' format." @@ -1801,4 +1802,5 @@ featureAllowLetOrUseBangTypeAnnotationWithoutParens,"Allow let! and use! type an 3878,tcAttributeIsNotValidForUnionCaseWithFields,"This attribute is not valid for use on union cases with fields." 3879,xmlDocNotFirstOnLine,"XML documentation comments should be the first non-whitespace text on a line." featureReturnFromFinal,"Support for ReturnFromFinal/YieldFromFinal in computation expressions to enable tailcall optimization when available on the builder." -3879,optsLangVersionOutOfSupport,"Language version '%s' is out of support. The last .NET SDK supporting it is available at https://dotnet.microsoft.com/en-us/download/dotnet/%s" +3880,optsLangVersionOutOfSupport,"Language version '%s' is out of support. The last .NET SDK supporting it is available at https://dotnet.microsoft.com/en-us/download/dotnet/%s" +3881,optsUnrecognizedLanguageFeature,"Unrecognized language feature name: '%s'. Use a valid feature name such as 'NameOf' or 'StringInterpolation'." \ No newline at end of file diff --git a/src/Compiler/Facilities/LanguageFeatures.fs b/src/Compiler/Facilities/LanguageFeatures.fs index 09fbf5e599..cc68e80153 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fs +++ b/src/Compiler/Facilities/LanguageFeatures.fs @@ -106,7 +106,7 @@ type LanguageFeature = | ReturnFromFinal /// LanguageVersion management -type LanguageVersion(versionText) = +type LanguageVersion(versionText, ?disabledFeaturesArray: LanguageFeature array) = // When we increment language versions here preview is higher than current RTM version static let languageVersion46 = 4.6m @@ -277,11 +277,22 @@ type LanguageVersion(versionText) = let specifiedString = versionToString specified + let disabledFeatures: LanguageFeature array = defaultArg disabledFeaturesArray [||] + + /// Get the disabled features + member _.DisabledFeatures = disabledFeatures + /// Check if this feature is supported by the selected langversion member _.SupportsFeature featureId = - match features.TryGetValue featureId with - | true, v -> v <= specified - | false, _ -> false + if Array.contains featureId disabledFeatures then + false + else + match features.TryGetValue featureId with + | true, v -> v <= specified + | false, _ -> false + + /// Create a new LanguageVersion with updated disabled features + member _.WithDisabledFeatures(disabled: LanguageFeature array) = LanguageVersion(versionText, disabled) /// Has preview been explicitly specified member _.IsExplicitlySpecifiedAs50OrBefore() = @@ -426,11 +437,38 @@ type LanguageVersion(versionText) = | true, v -> versionToString v | _ -> invalidArg "feature" "Internal error: Unable to find feature." + /// Try to parse a feature name string to a LanguageFeature option using reflection + static member TryParseFeature(featureName: string) = + let normalized = featureName.Trim() + + let bindingFlags = + System.Reflection.BindingFlags.Public + ||| System.Reflection.BindingFlags.NonPublic + + Microsoft.FSharp.Reflection.FSharpType.GetUnionCases(typeof, bindingFlags) + |> Array.tryFind (fun case -> System.String.Equals(case.Name, normalized, System.StringComparison.OrdinalIgnoreCase)) + |> Option.bind (fun case -> + let union = + Microsoft.FSharp.Reflection.FSharpValue.MakeUnion(case, [||], bindingFlags) + + match box union with + | null -> None + | obj -> Some(obj :?> LanguageFeature)) + override x.Equals(yobj: obj) = match yobj with - | :? LanguageVersion as y -> x.SpecifiedVersion = y.SpecifiedVersion + | :? LanguageVersion as y -> + x.SpecifiedVersion = y.SpecifiedVersion + && x.DisabledFeatures.Length = y.DisabledFeatures.Length + && (x.DisabledFeatures, y.DisabledFeatures) ||> Array.forall2 (=) | _ -> false - override x.GetHashCode() = hash x.SpecifiedVersion + override x.GetHashCode() = + let mutable h = hash x.SpecifiedVersion + + for f in x.DisabledFeatures do + h <- h ^^^ hash f + + h static member Default = defaultLanguageVersion diff --git a/src/Compiler/Facilities/LanguageFeatures.fsi b/src/Compiler/Facilities/LanguageFeatures.fsi index cc5a7a20f9..09cb427357 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fsi +++ b/src/Compiler/Facilities/LanguageFeatures.fsi @@ -100,7 +100,7 @@ type LanguageFeature = type LanguageVersion = /// Create a LanguageVersion management object - new: string -> LanguageVersion + new: string * ?disabledFeaturesArray: LanguageFeature array -> LanguageVersion /// Is the selected LanguageVersion valid static member ContainsVersion: string -> bool @@ -117,6 +117,12 @@ type LanguageVersion = /// Does the selected LanguageVersion support the specified feature member SupportsFeature: LanguageFeature -> bool + /// Get the disabled features + member DisabledFeatures: LanguageFeature array + + /// Create a new LanguageVersion with updated disabled features + member WithDisabledFeatures: LanguageFeature array -> LanguageVersion + /// Get the list of valid versions static member ValidVersions: string[] @@ -138,4 +144,7 @@ type LanguageVersion = /// Get a version string associated with the given feature. static member GetFeatureVersionString: feature: LanguageFeature -> string + /// Try to parse a feature name string to a LanguageFeature option + static member TryParseFeature: featureName: string -> LanguageFeature option + static member Default: LanguageVersion diff --git a/src/Compiler/Service/IncrementalBuild.fs b/src/Compiler/Service/IncrementalBuild.fs index 5580e161ba..52499fd63c 100644 --- a/src/Compiler/Service/IncrementalBuild.fs +++ b/src/Compiler/Service/IncrementalBuild.fs @@ -556,7 +556,7 @@ type FrameworkImportsCache(size) = // for each cached project. So here we create a new tcGlobals, with the existing framework values // and updated realsig and langversion let tcGlobals = - if tcGlobals.langVersion.SpecifiedVersion <> tcConfig.langVersion.SpecifiedVersion + if tcGlobals.langVersion <> tcConfig.langVersion || tcGlobals.realsig <> tcConfig.realsig then TcGlobals( tcGlobals.compilingFSharpCore, diff --git a/src/Compiler/Service/TransparentCompiler.fs b/src/Compiler/Service/TransparentCompiler.fs index 9ef3474d05..f988858402 100644 --- a/src/Compiler/Service/TransparentCompiler.fs +++ b/src/Compiler/Service/TransparentCompiler.fs @@ -490,7 +490,12 @@ type internal TransparentCompiler let applyCompilerOptions tcConfig = let fsiCompilerOptions = GetCoreFsiCompilerOptions tcConfig - ParseCompilerOptions(ignore, fsiCompilerOptions, otherOptions) + + try + ParseCompilerOptions(ignore, fsiCompilerOptions, otherOptions) + with + | :? OperationCanceledException -> reraise () + | exn -> errorRecovery exn range0 let closure = LoadClosure.ComputeClosureOfScriptText( @@ -900,8 +905,16 @@ type internal TransparentCompiler tcConfigB.useSimpleResolution <- useSimpleResolution // Apply command-line arguments and collect more source files if they are in the arguments + // Wrap in try/catch to ensure command-line parsing errors are properly captured + // as diagnostics rather than escaping as exceptions let sourceFilesNew = - ApplyCommandLineArgs(tcConfigB, projectSnapshot.SourceFileNames, commandLineArgs) + try + ApplyCommandLineArgs(tcConfigB, projectSnapshot.SourceFileNames, commandLineArgs) + with + | :? OperationCanceledException -> reraise () + | exn -> + errorRecovery exn range0 + projectSnapshot.SourceFileNames // Never open PDB files for the language service, even if --standalone is specified tcConfigB.openDebugInformationForLaterStaticLinking <- false @@ -949,6 +962,33 @@ type internal TransparentCompiler // Prepare the frameworkTcImportsCache let! tcGlobals, frameworkTcImports = ComputeFrameworkImports tcConfig frameworkDLLs nonFrameworkResolutions + // If the tcGlobals was loaded from a different project, langVersion and realsig may be different + // for each cached project. So here we create a new tcGlobals, with the existing framework values + // and updated realsig and langversion + let tcGlobals = + if + tcGlobals.langVersion <> tcConfig.langVersion + || tcGlobals.realsig <> tcConfig.realsig + then + TcGlobals( + tcGlobals.compilingFSharpCore, + tcGlobals.ilg, + tcGlobals.fslibCcu, + tcGlobals.directoryToResolveRelativePaths, + tcGlobals.isInteractive, + tcGlobals.checkNullness, + tcGlobals.useReflectionFreeCodeGen, + tcGlobals.tryFindSysTypeCcuHelper, + tcGlobals.emitDebugInfoInQuotations, + tcGlobals.noDebugAttributes, + tcGlobals.pathMap, + tcConfig.langVersion, + tcConfig.realsig, + tcConfig.compilationMode + ) + else + tcGlobals + // Note we are not calling diagnosticsLogger.GetDiagnostics() anywhere for this task. // This is ok because not much can actually go wrong here. let diagnosticsLogger = @@ -1013,7 +1053,6 @@ type internal TransparentCompiler let computeBootstrapInfoInner (projectSnapshot: ProjectSnapshot) = async { - let! tcConfigB, sourceFiles, loadClosureOpt = ComputeTcConfigBuilder projectSnapshot // If this is a builder for a script, re-apply the settings inferred from the diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index a16069a991..ace369ab6d 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -987,6 +987,11 @@ Compress interface and optimization data files ({0} by default) + + Disable a specific language feature by name. + Disable a specific language feature by name. + + Display the allowed values for language version. Zobrazí povolené hodnoty pro jazykovou verzi. @@ -1072,6 +1077,11 @@ Neplatná hodnota „{0}“ pro --interfacedata, platná hodnota je: none, file, compress. + + Unrecognized language feature name: '{0}'. Use a valid feature name such as 'NameOf' or 'StringInterpolation'. + Unrecognized language feature name: '{0}'. Use a valid feature name such as 'NameOf' or 'StringInterpolation'. + + Unrecognized value '{0}' for --langversion use --langversion:? for complete list Nerozpoznaná hodnota {0} pro parametr --langversion; seznam možností zobrazíte zadáním --langversion:? diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 9d14ac7186..b085382559 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -987,6 +987,11 @@ Compress interface and optimization data files ({0} by default) + + Disable a specific language feature by name. + Disable a specific language feature by name. + + Display the allowed values for language version. Anzeigen der zulässigen Werte für die Sprachversion. @@ -1072,6 +1077,11 @@ Ungültiger Wert „{0}“ für --interfacedata. Gültige Werte sind: none, file, compress. + + Unrecognized language feature name: '{0}'. Use a valid feature name such as 'NameOf' or 'StringInterpolation'. + Unrecognized language feature name: '{0}'. Use a valid feature name such as 'NameOf' or 'StringInterpolation'. + + Unrecognized value '{0}' for --langversion use --langversion:? for complete list Unbekannter Wert "{0}" für "--langversion". Verwenden Sie "--langversion:?", um die vollständige Liste anzuzeigen. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 20b4096076..ce366b2aa2 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -987,6 +987,11 @@ Compress interface and optimization data files ({0} by default) + + Disable a specific language feature by name. + Disable a specific language feature by name. + + Display the allowed values for language version. Muestra los valores permitidos para la versión del lenguaje. @@ -1072,6 +1077,11 @@ Valor no válido '{0}' para --interfacedata; los valores válidos son: none, file, compress. + + Unrecognized language feature name: '{0}'. Use a valid feature name such as 'NameOf' or 'StringInterpolation'. + Unrecognized language feature name: '{0}'. Use a valid feature name such as 'NameOf' or 'StringInterpolation'. + + Unrecognized value '{0}' for --langversion use --langversion:? for complete list Valor no reconocido "{0}" para --langversion, use --langversion:? para una lista completa diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index fa5cdbc9b4..434fe52667 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -987,6 +987,11 @@ Compress interface and optimization data files ({0} by default) + + Disable a specific language feature by name. + Disable a specific language feature by name. + + Display the allowed values for language version. Affichez les valeurs autorisées pour la version du langage. @@ -1072,6 +1077,11 @@ Valeur non valide '{0}' pour --interfacedata. Les valeurs valides sont : none, file, compress. + + Unrecognized language feature name: '{0}'. Use a valid feature name such as 'NameOf' or 'StringInterpolation'. + Unrecognized language feature name: '{0}'. Use a valid feature name such as 'NameOf' or 'StringInterpolation'. + + Unrecognized value '{0}' for --langversion use --langversion:? for complete list Valeur non reconnue '{0}' pour --langversion use --langversion:? pour la liste complète diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index ab44c6ed17..b56cbd0aac 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -987,6 +987,11 @@ Compress interface and optimization data files ({0} by default) + + Disable a specific language feature by name. + Disable a specific language feature by name. + + Display the allowed values for language version. Visualizzare i valori consentiti per la versione della lingua. @@ -1072,6 +1077,11 @@ Valore non valido '{0}' per --interfacedata. Valori validi sono: none, file, compress. + + Unrecognized language feature name: '{0}'. Use a valid feature name such as 'NameOf' or 'StringInterpolation'. + Unrecognized language feature name: '{0}'. Use a valid feature name such as 'NameOf' or 'StringInterpolation'. + + Unrecognized value '{0}' for --langversion use --langversion:? for complete list Valore '{0}' non riconosciuto per --langversion. Per l'elenco completo usare --langversion:? diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 26873be4ee..4c30fd2c58 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -987,6 +987,11 @@ Compress interface and optimization data files ({0} by default) + + Disable a specific language feature by name. + Disable a specific language feature by name. + + Display the allowed values for language version. 言語バージョンで許可されている値を表示します。 @@ -1072,6 +1077,11 @@ --interfacedata の値 '{0}' が無効です。有効な値は none、file、compress です。 + + Unrecognized language feature name: '{0}'. Use a valid feature name such as 'NameOf' or 'StringInterpolation'. + Unrecognized language feature name: '{0}'. Use a valid feature name such as 'NameOf' or 'StringInterpolation'. + + Unrecognized value '{0}' for --langversion use --langversion:? for complete list --langversion の値 '{0}' が認識されません。完全なリストについては、--langversion:? を使用してください diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 6df9b75af6..cfad9f364e 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -987,6 +987,11 @@ Compress interface and optimization data files ({0} by default) + + Disable a specific language feature by name. + Disable a specific language feature by name. + + Display the allowed values for language version. 언어 버전에 허용되는 값을 표시합니다. @@ -1072,6 +1077,11 @@ --interfacedata에 대한 '{0}' 값이 잘못되었습니다. 올바른 값은 none, file, compress입니다. + + Unrecognized language feature name: '{0}'. Use a valid feature name such as 'NameOf' or 'StringInterpolation'. + Unrecognized language feature name: '{0}'. Use a valid feature name such as 'NameOf' or 'StringInterpolation'. + + Unrecognized value '{0}' for --langversion use --langversion:? for complete list 전체 목록에 대한 --langversion use --langversion:?의 인식할 수 없는 값 '{0}'입니다. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 3d5d08397e..70d3104761 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -987,6 +987,11 @@ Compress interface and optimization data files ({0} by default) + + Disable a specific language feature by name. + Disable a specific language feature by name. + + Display the allowed values for language version. Wyświetl dozwolone wartości dla wersji językowej. @@ -1072,6 +1077,11 @@ Nieprawidłowa wartość „{0}” dla parametru --interfacedata, prawidłowa wartość to: none, file, compress. + + Unrecognized language feature name: '{0}'. Use a valid feature name such as 'NameOf' or 'StringInterpolation'. + Unrecognized language feature name: '{0}'. Use a valid feature name such as 'NameOf' or 'StringInterpolation'. + + Unrecognized value '{0}' for --langversion use --langversion:? for complete list Nierozpoznana wartość „{0}” dla parametru –langversion; podaj parametr –langversion:?, aby uzyskać pełną listę diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 6ce3a9ee12..bfe7eec527 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -987,6 +987,11 @@ Compress interface and optimization data files ({0} by default) + + Disable a specific language feature by name. + Disable a specific language feature by name. + + Display the allowed values for language version. Exiba os valores permitidos para a versão do idioma. @@ -1072,6 +1077,11 @@ Valor inválido '{0}' para --interfacedata, o valor válido é: none, file, compact. + + Unrecognized language feature name: '{0}'. Use a valid feature name such as 'NameOf' or 'StringInterpolation'. + Unrecognized language feature name: '{0}'. Use a valid feature name such as 'NameOf' or 'StringInterpolation'. + + Unrecognized value '{0}' for --langversion use --langversion:? for complete list Valor não reconhecido '{0}' para --langversion use --langversion:? para a lista completa diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 3de8425da8..426e70c647 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -987,6 +987,11 @@ Compress interface and optimization data files ({0} by default) + + Disable a specific language feature by name. + Disable a specific language feature by name. + + Display the allowed values for language version. Отображение допустимых значений для версии языка. @@ -1072,6 +1077,11 @@ Недопустимое значение "{0}" для --interfacedata. Допустимые значения: none, file, compress. + + Unrecognized language feature name: '{0}'. Use a valid feature name such as 'NameOf' or 'StringInterpolation'. + Unrecognized language feature name: '{0}'. Use a valid feature name such as 'NameOf' or 'StringInterpolation'. + + Unrecognized value '{0}' for --langversion use --langversion:? for complete list Не удалось распознать значение "{0}" для параметра --langversion. Для получения полного списка допустимых значений выполните команду use --langversion:? diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 8f72abc55f..1908a5b1ee 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -987,6 +987,11 @@ Compress interface and optimization data files ({0} by default) + + Disable a specific language feature by name. + Disable a specific language feature by name. + + Display the allowed values for language version. Dil sürümü için izin verilen değerleri görüntüleyin. @@ -1072,6 +1077,11 @@ --interfacedata için geçersiz '{0}' değeri, geçerli değerler: none, file, compress. + + Unrecognized language feature name: '{0}'. Use a valid feature name such as 'NameOf' or 'StringInterpolation'. + Unrecognized language feature name: '{0}'. Use a valid feature name such as 'NameOf' or 'StringInterpolation'. + + Unrecognized value '{0}' for --langversion use --langversion:? for complete list --langversion için '{0}' değeri tanınmıyor. Tam liste için --langversion:? kullanın diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index eddb44422c..686eb4f48b 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -987,6 +987,11 @@ Compress interface and optimization data files ({0} by default) + + Disable a specific language feature by name. + Disable a specific language feature by name. + + Display the allowed values for language version. 显示语言版本的允许值。 @@ -1072,6 +1077,11 @@ --interfacedata 的值 "{0}" 无效,有效值为: none、file、compress。 + + Unrecognized language feature name: '{0}'. Use a valid feature name such as 'NameOf' or 'StringInterpolation'. + Unrecognized language feature name: '{0}'. Use a valid feature name such as 'NameOf' or 'StringInterpolation'. + + Unrecognized value '{0}' for --langversion use --langversion:? for complete list --langversion 的值“{0}”无法识别,使用 --langversion:? 获取完整列表。 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index ab9923778e..bf14e4068e 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -987,6 +987,11 @@ Compress interface and optimization data files ({0} by default) + + Disable a specific language feature by name. + Disable a specific language feature by name. + + Display the allowed values for language version. 顯示語言版本的允許值。 @@ -1072,6 +1077,11 @@ --interfacedata 的 '{0}' 值無效,有效值為: none、file、compress。 + + Unrecognized language feature name: '{0}'. Use a valid feature name such as 'NameOf' or 'StringInterpolation'. + Unrecognized language feature name: '{0}'. Use a valid feature name such as 'NameOf' or 'StringInterpolation'. + + Unrecognized value '{0}' for --langversion use --langversion:? for complete list 對 --langversion 為無法識別的值 '{0}',對完整清單使用 --langversion:? diff --git a/src/FSharp.Build/Fsc.fs b/src/FSharp.Build/Fsc.fs index 8274812fcb..62934bfe85 100644 --- a/src/FSharp.Build/Fsc.fs +++ b/src/FSharp.Build/Fsc.fs @@ -42,6 +42,7 @@ type public Fsc() as this = let mutable highEntropyVA: bool = false let mutable keyFile: string MaybeNull = null let mutable langVersion: string MaybeNull = null + let mutable disabledLanguageFeatures: ITaskItem[] = [||] let mutable noFramework = false let mutable noInterfaceData = false let mutable noOptimizationData = false @@ -152,6 +153,9 @@ type public Fsc() as this = builder.AppendSwitchIfNotNull("--langversion:", langVersion) + for item in disabledLanguageFeatures do + builder.AppendSwitchIfNotNull("--disableLanguageFeature:", item.ItemSpec) + // NoFramework if noFramework then builder.AppendSwitch("--noframework") @@ -463,6 +467,10 @@ type public Fsc() as this = with get () = langVersion and set (s) = langVersion <- s + member _.DisabledLanguageFeatures + with get () = disabledLanguageFeatures + and set (a) = disabledLanguageFeatures <- a + member _.LCID with get () = vslcid and set (p) = vslcid <- p diff --git a/src/FSharp.Build/Microsoft.FSharp.Targets b/src/FSharp.Build/Microsoft.FSharp.Targets index a1385f6aff..9049f2f711 100644 --- a/src/FSharp.Build/Microsoft.FSharp.Targets +++ b/src/FSharp.Build/Microsoft.FSharp.Targets @@ -371,6 +371,7 @@ this file. HighEntropyVA="$(HighEntropyVA)" KeyFile="$(KeyOriginatorFile)" LangVersion="$(LangVersion)" + DisabledLanguageFeatures="@(DisabledLanguageFeatures)" LCID="$(LCID)" NoFramework="true" NoInterfaceData="$(NoInterfaceData)" diff --git a/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/disableLanguageFeature.fs b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/disableLanguageFeature.fs new file mode 100644 index 0000000000..c69ffd3537 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/disableLanguageFeature.fs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace CompilerOptions.Fsc + +open Xunit +open FSharp.Test +open FSharp.Test.Compiler + +module disableLanguageFeature = + + [] + let ``disableLanguageFeature with valid feature name should typecheck successfully``() = + FSharp """ +printfn "Hello, World" + """ + |> withOptions ["--disableLanguageFeature:NameOf"] + |> typecheck + |> shouldSucceed + |> ignore + + [] + let ``disableLanguageFeature should disable NameOf feature``() = + // nameof with type parameter requires LanguageFeature.NameOf + FSharp """ +let f<'T>() = nameof<'T> + """ + |> withOptions ["--langversion:latest"; "--disableLanguageFeature:NameOf"] + |> typecheck + |> shouldFail + |> withErrorCode 39 + |> withDiagnosticMessageMatches "The value or constructor 'nameof' is not defined" + |> ignore + + [] + let ``disableLanguageFeature should disable NestedCopyAndUpdate feature``() = + // Nested copy and update requires LanguageFeature.NestedCopyAndUpdate + FSharp """ +type Inner = { X: int } +type Outer = { Inner: Inner } +let o = { Inner = { X = 1 } } +let o2 = { o with Inner.X = 2 } + """ + |> withOptions ["--langversion:latest"; "--disableLanguageFeature:NestedCopyAndUpdate"] + |> typecheck + |> shouldFail + |> ignore + + [] + let ``disableLanguageFeature with invalid feature name should fail``() = + FSharp """ +printfn "Hello, World" + """ + |> withOptions ["--disableLanguageFeature:InvalidFeatureName"] + |> typecheck + |> shouldFail + |> withErrorCode 3881 + |> withDiagnosticMessageMatches "Unrecognized language feature name" + |> ignore + + [] + let ``disableLanguageFeature can be used multiple times``() = + // nameof with type parameter requires LanguageFeature.NameOf + FSharp """ +let f<'T>() = nameof<'T> + """ + |> withOptions ["--langversion:latest"; "--disableLanguageFeature:NameOf"; "--disableLanguageFeature:StringInterpolation"] + |> typecheck + |> shouldFail + |> withErrorCode 39 + |> ignore + + [] + let ``disableLanguageFeature is case insensitive``() = + // nameof with type parameter requires LanguageFeature.NameOf + FSharp """ +let f<'T>() = nameof<'T> + """ + |> withOptions ["--langversion:latest"; "--disableLanguageFeature:nameof"] + |> typecheck + |> shouldFail + |> withErrorCode 39 + |> ignore diff --git a/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/misc/compiler_help_output.bsl b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/misc/compiler_help_output.bsl index de2138d2e7..3cfd389dc8 100644 --- a/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/misc/compiler_help_output.bsl +++ b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/misc/compiler_help_output.bsl @@ -80,6 +80,7 @@ Copyright (c) Microsoft Corporation. All Rights Reserved. - LANGUAGE - --langversion:? Display the allowed values for language version. --langversion:{version|latest|preview} Specify language version such as 'latest' or 'preview'. +--disableLanguageFeature: Disable a specific language feature by name. --checked[+|-] Generate overflow checks (off by default) --define: Define conditional compilation symbols (Short form: -d) --strict-indentation[+|-] Override indentation rules implied by the language version (off by default) diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index 2b37b2cf7e..035dbe3d9c 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -301,6 +301,7 @@ + diff --git a/tests/FSharp.Compiler.Service.Tests/expected-help-output.bsl b/tests/FSharp.Compiler.Service.Tests/expected-help-output.bsl index 3bafcb8969..8b112b0dad 100644 --- a/tests/FSharp.Compiler.Service.Tests/expected-help-output.bsl +++ b/tests/FSharp.Compiler.Service.Tests/expected-help-output.bsl @@ -122,6 +122,8 @@ language version. --langversion:{version|latest|preview} Specify language version such as 'latest' or 'preview'. +--disableLanguageFeature: Disable a specific language feature + by name. --checked[+|-] Generate overflow checks (off by default) --define: Define conditional compilation diff --git a/tests/ILVerify/ilverify_FSharp.Compiler.Service_Debug_net10.0.bsl b/tests/ILVerify/ilverify_FSharp.Compiler.Service_Debug_net10.0.bsl index 203ed9f800..045a12aaae 100644 --- a/tests/ILVerify/ilverify_FSharp.Compiler.Service_Debug_net10.0.bsl +++ b/tests/ILVerify/ilverify_FSharp.Compiler.Service_Debug_net10.0.bsl @@ -39,8 +39,8 @@ [IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerOptions+attempt::Invoke([FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1)][offset 0x00000E9F][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.ParseAndCheckInputs+::Invoke(int32)][offset 0x00000030][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.ParseAndCheckInputs+::Invoke(int32)][offset 0x00000039][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerConfig+TcConfig::.ctor([FSharp.Compiler.Service]FSharp.Compiler.CompilerConfig+TcConfigBuilder, bool)][offset 0x0000061D][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerConfig+TcConfig::.ctor([FSharp.Compiler.Service]FSharp.Compiler.CompilerConfig+TcConfigBuilder, bool)][offset 0x00000626][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerConfig+TcConfig::.ctor([FSharp.Compiler.Service]FSharp.Compiler.CompilerConfig+TcConfigBuilder, bool)][offset 0x00000624][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerConfig+TcConfig::.ctor([FSharp.Compiler.Service]FSharp.Compiler.CompilerConfig+TcConfigBuilder, bool)][offset 0x0000062D][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.PatternMatchCompilation::isProblematicClause([FSharp.Compiler.Service]FSharp.Compiler.PatternMatchCompilation+MatchClause)][offset 0x00000065][found Byte] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : .$FSharp.Compiler.PatternMatchCompilation::.cctor()][offset 0x00000015][found Boolean] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.TypeProviders::ValidateExpectedName([FSharp.Compiler.Service]FSharp.Compiler.Text.Range, string[], string, [FSharp.Compiler.Service]FSharp.Compiler.Tainted`1)][offset 0x000000AD][found Char] Unexpected type on the stack. diff --git a/tests/ILVerify/ilverify_FSharp.Compiler.Service_Debug_netstandard2.0.bsl b/tests/ILVerify/ilverify_FSharp.Compiler.Service_Debug_netstandard2.0.bsl index c584493399..fef4a9e484 100644 --- a/tests/ILVerify/ilverify_FSharp.Compiler.Service_Debug_netstandard2.0.bsl +++ b/tests/ILVerify/ilverify_FSharp.Compiler.Service_Debug_netstandard2.0.bsl @@ -28,8 +28,8 @@ [IL]: Error [StackUnexpected]: : FSharp.Compiler.CodeAnalysis.Hosted.CompilerHelpers::fscCompile([FSharp.Compiler.Service]FSharp.Compiler.CodeAnalysis.LegacyReferenceResolver, string, string[])][offset 0x0000008B][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.Interactive.Shell+FsiStdinSyphon::GetLine(string, int32)][offset 0x00000039][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.Interactive.Shell+MagicAssemblyResolution::ResolveAssemblyCore([FSharp.Compiler.Service]Internal.Utilities.Library.CompilationThreadToken, [FSharp.Compiler.Service]FSharp.Compiler.Text.Range, [FSharp.Compiler.Service]FSharp.Compiler.CompilerConfig+TcConfigBuilder, [FSharp.Compiler.Service]FSharp.Compiler.CompilerImports+TcImports, [FSharp.Compiler.Service]FSharp.Compiler.Interactive.Shell+FsiDynamicCompiler, [FSharp.Compiler.Service]FSharp.Compiler.Interactive.Shell+FsiConsoleOutput, string)][offset 0x00000015][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : FSharp.Compiler.Interactive.Shell+clo::Invoke([S.P.CoreLib]System.Tuple`3)][offset 0x000001E5][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.Interactive.Shell+FsiInteractionProcessor::CompletionsForPartialLID([FSharp.Compiler.Service]FSharp.Compiler.Interactive.Shell+FsiDynamicCompilerState, string)][offset 0x0000001B][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : FSharp.Compiler.Interactive.Shell+clo::Invoke([S.P.CoreLib]System.Tuple`3)][offset 0x000001E5][found Char] Unexpected type on the stack. [IL]: Error [UnmanagedPointer]: : FSharp.Compiler.Interactive.Shell+Utilities+pointerToNativeInt::Invoke(object)][offset 0x00000007] Unmanaged pointers are not a verifiable type. [IL]: Error [StackUnexpected]: : .$FSharpCheckerResults+dataTipOfReferences::Invoke([FSharp.Core]Microsoft.FSharp.Core.Unit)][offset 0x00000084][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.EditorServices.AssemblyContent+traverseMemberFunctionAndValues::Invoke([FSharp.Compiler.Service]FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue)][offset 0x00000059][found Char] Unexpected type on the stack. @@ -56,8 +56,8 @@ [IL]: Error [StackUnexpected]: : FSharp.Compiler.ParseAndCheckInputs+::Invoke(int32)][offset 0x00000030][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.ParseAndCheckInputs+::Invoke(int32)][offset 0x00000039][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerImports+line::Invoke(string)][offset 0x0000000B][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerConfig+TcConfig::.ctor([FSharp.Compiler.Service]FSharp.Compiler.CompilerConfig+TcConfigBuilder, bool)][offset 0x0000061D][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerConfig+TcConfig::.ctor([FSharp.Compiler.Service]FSharp.Compiler.CompilerConfig+TcConfigBuilder, bool)][offset 0x00000626][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerConfig+TcConfig::.ctor([FSharp.Compiler.Service]FSharp.Compiler.CompilerConfig+TcConfigBuilder, bool)][offset 0x00000624][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerConfig+TcConfig::.ctor([FSharp.Compiler.Service]FSharp.Compiler.CompilerConfig+TcConfigBuilder, bool)][offset 0x0000062D][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.PatternMatchCompilation::isProblematicClause([FSharp.Compiler.Service]FSharp.Compiler.PatternMatchCompilation+MatchClause)][offset 0x00000065][found Byte] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : .$FSharp.Compiler.PatternMatchCompilation::.cctor()][offset 0x00000015][found Boolean] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.NicePrint+TastDefinitionPrinting+meths::Invoke([FSharp.Compiler.Service]FSharp.Compiler.Infos+MethInfo)][offset 0x000000BE][found Char] Unexpected type on the stack. diff --git a/tests/ILVerify/ilverify_FSharp.Compiler.Service_Release_net10.0.bsl b/tests/ILVerify/ilverify_FSharp.Compiler.Service_Release_net10.0.bsl index f3f3611b02..ea8b049c0f 100644 --- a/tests/ILVerify/ilverify_FSharp.Compiler.Service_Release_net10.0.bsl +++ b/tests/ILVerify/ilverify_FSharp.Compiler.Service_Release_net10.0.bsl @@ -32,17 +32,17 @@ [IL]: Error [StackUnexpected]: : FSharp.Compiler.Driver+ProcessCommandLineFlags::Invoke(string)][offset 0x00000014][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.StaticLinking+TypeForwarding::followTypeForwardForILTypeRef([FSharp.Compiler.Service]FSharp.Compiler.AbstractIL.IL+ILTypeRef)][offset 0x00000010][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerOptions::getCompilerOption([FSharp.Compiler.Service]FSharp.Compiler.CompilerOptions+CompilerOption, [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1)][offset 0x000000A7][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerOptions::AddPathMapping([FSharp.Compiler.Service]FSharp.Compiler.CompilerConfig+TcConfigBuilder, string)][offset 0x0000000B][found Char] Unexpected type on the stack. +[IL]: Error [StackUnderflow]: : FSharp.Compiler.CompilerOptions::DoWithColor([System.Console]System.ConsoleColor, [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2)][offset 0x0000005E] Stack underflow. [IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerOptions::parseOption(string)][offset 0x0000000B][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerOptions::getOptionArgList([FSharp.Compiler.Service]FSharp.Compiler.CompilerOptions+CompilerOption, string)][offset 0x00000049][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerOptions::getOptionArgList([FSharp.Compiler.Service]FSharp.Compiler.CompilerOptions+CompilerOption, string)][offset 0x00000052][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerOptions::getSwitch(string)][offset 0x0000000B][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerOptions::attempt([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2, [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1, [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1, [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1, string, string, string, string, [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1)][offset 0x00000A99][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerOptions::AddPathMapping([FSharp.Compiler.Service]FSharp.Compiler.CompilerConfig+TcConfigBuilder, string)][offset 0x0000000B][found Char] Unexpected type on the stack. -[IL]: Error [StackUnderflow]: : FSharp.Compiler.CompilerOptions::DoWithColor([System.Console]System.ConsoleColor, [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2)][offset 0x0000005E] Stack underflow. [IL]: Error [StackUnexpected]: : FSharp.Compiler.ParseAndCheckInputs+CheckMultipleInputsUsingGraphMode::Invoke(int32)][offset 0x00000031][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.ParseAndCheckInputs+CheckMultipleInputsUsingGraphMode::Invoke(int32)][offset 0x0000003A][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerConfig+TcConfig::.ctor([FSharp.Compiler.Service]FSharp.Compiler.CompilerConfig+TcConfigBuilder, bool)][offset 0x00000590][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerConfig+TcConfig::.ctor([FSharp.Compiler.Service]FSharp.Compiler.CompilerConfig+TcConfigBuilder, bool)][offset 0x00000599][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerConfig+TcConfig::.ctor([FSharp.Compiler.Service]FSharp.Compiler.CompilerConfig+TcConfigBuilder, bool)][offset 0x00000596][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerConfig+TcConfig::.ctor([FSharp.Compiler.Service]FSharp.Compiler.CompilerConfig+TcConfigBuilder, bool)][offset 0x0000059F][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.IlxGen::HashRangeSorted([S.P.CoreLib]System.Collections.Generic.IDictionary`2>)][offset 0x00000011][found ref '[FSharp.Compiler.Service]FSharp.Compiler.IlxGen+HashRangeSorted'][expected ref '[FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,int32>'] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.IlxGen::HashRangeSorted([S.P.CoreLib]System.Collections.Generic.IDictionary`2>)][offset 0x00000012][found ref '[FSharp.Compiler.Service]FSharp.Compiler.IlxGen+HashRangeSorted'][expected ref '[FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,T0>'] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.PatternMatchCompilation::isProblematicClause([FSharp.Compiler.Service]FSharp.Compiler.PatternMatchCompilation+MatchClause)][offset 0x00000040][found Byte] Unexpected type on the stack. @@ -74,8 +74,8 @@ [IL]: Error [StackUnexpected]: : FSharp.Compiler.AbstractIL.ILBinaryReader::seekReadNestedRowUncached([FSharp.Core]Microsoft.FSharp.Core.FSharpRef`1>, int32)][offset 0x00000038][found Byte] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.AbstractIL.ILBinaryReader::seekReadNestedRowUncached([FSharp.Core]Microsoft.FSharp.Core.FSharpRef`1>, int32)][offset 0x00000058][found Byte] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.AbstractIL.ILBinaryReader::seekReadGenericParamConstraintIdx([FSharp.Compiler.Service]FSharp.Compiler.AbstractIL.ILBinaryReader+ILMetadataReader, [FSharp.Compiler.Service]FSharp.Compiler.IO.ReadOnlyByteMemory, int32)][offset 0x00000025][found Byte] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : FSharp.Compiler.AbstractIL.ILBinaryReader::rowKindSize$cont(bool, bool, bool, bool[], bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1, [FSharp.Core]Microsoft.FSharp.Core.Unit)][offset 0x000000E5][found Byte] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.AbstractIL.ILBinaryReader::openMetadataReader(string, [FSharp.Compiler.Service]FSharp.Compiler.AbstractIL.ILBinaryReader+BinaryFile, int32, [S.P.CoreLib]System.Tuple`8,bool,bool,bool,bool,bool,System.Tuple`5,bool,int32,int32,int32>>, [FSharp.Compiler.Service]FSharp.Compiler.AbstractIL.ILBinaryReader+PEReader, [FSharp.Compiler.Service]FSharp.Compiler.IO.ReadOnlyByteMemory, [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1, bool)][offset 0x000006B6][found Boolean] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : FSharp.Compiler.AbstractIL.ILBinaryReader::rowKindSize$cont(bool, bool, bool, bool[], bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1, [FSharp.Core]Microsoft.FSharp.Core.Unit)][offset 0x000000E5][found Byte] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.AbstractIL.ILBinaryReader+seekReadInterfaceImpls::Invoke(int32)][offset 0x0000002F][found Byte] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.AbstractIL.ILBinaryReader+seekReadGenericParamConstraints::Invoke(int32)][offset 0x0000002F][found Byte] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.AbstractIL.ILBinaryReader+enclIdx::Invoke(int32)][offset 0x0000002F][found Byte] Unexpected type on the stack. diff --git a/tests/ILVerify/ilverify_FSharp.Compiler.Service_Release_netstandard2.0.bsl b/tests/ILVerify/ilverify_FSharp.Compiler.Service_Release_netstandard2.0.bsl index ac58318665..eb7eb08379 100644 --- a/tests/ILVerify/ilverify_FSharp.Compiler.Service_Release_netstandard2.0.bsl +++ b/tests/ILVerify/ilverify_FSharp.Compiler.Service_Release_netstandard2.0.bsl @@ -28,8 +28,8 @@ [IL]: Error [StackUnexpected]: : FSharp.Compiler.CodeAnalysis.Hosted.CompilerHelpers::fscCompile([FSharp.Compiler.Service]FSharp.Compiler.CodeAnalysis.LegacyReferenceResolver, string, string[])][offset 0x0000008B][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.Interactive.Shell+FsiStdinSyphon::GetLine(string, int32)][offset 0x00000032][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.Interactive.Shell+MagicAssemblyResolution::ResolveAssemblyCore([FSharp.Compiler.Service]Internal.Utilities.Library.CompilationThreadToken, [FSharp.Compiler.Service]FSharp.Compiler.Text.Range, [FSharp.Compiler.Service]FSharp.Compiler.CompilerConfig+TcConfigBuilder, [FSharp.Compiler.Service]FSharp.Compiler.CompilerImports+TcImports, [FSharp.Compiler.Service]FSharp.Compiler.Interactive.Shell+FsiDynamicCompiler, [FSharp.Compiler.Service]FSharp.Compiler.Interactive.Shell+FsiConsoleOutput, string)][offset 0x00000015][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : FSharp.Compiler.Interactive.Shell+clo::Invoke([S.P.CoreLib]System.Tuple`3)][offset 0x000001C7][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.Interactive.Shell+FsiInteractionProcessor::CompletionsForPartialLID([FSharp.Compiler.Service]FSharp.Compiler.Interactive.Shell+FsiDynamicCompilerState, string)][offset 0x00000024][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : FSharp.Compiler.Interactive.Shell+clo::Invoke([S.P.CoreLib]System.Tuple`3)][offset 0x000001C7][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : .$FSharpCheckerResults+GetReferenceResolutionStructuredToolTipText::Invoke([FSharp.Core]Microsoft.FSharp.Core.Unit)][offset 0x00000076][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.EditorServices.AssemblyContent+traverseMemberFunctionAndValues::Invoke([FSharp.Compiler.Service]FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue)][offset 0x0000002B][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.EditorServices.AssemblyContent+traverseEntity::GenerateNext([S.P.CoreLib]System.Collections.Generic.IEnumerable`1&)][offset 0x000000BB][found Char] Unexpected type on the stack. @@ -45,22 +45,22 @@ [IL]: Error [StackUnexpected]: : FSharp.Compiler.CreateILModule+MainModuleBuilder::ConvertProductVersionToILVersionInfo(string)][offset 0x00000010][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.StaticLinking+TypeForwarding::followTypeForwardForILTypeRef([FSharp.Compiler.Service]FSharp.Compiler.AbstractIL.IL+ILTypeRef)][offset 0x00000010][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerOptions::getCompilerOption([FSharp.Compiler.Service]FSharp.Compiler.CompilerOptions+CompilerOption, [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1)][offset 0x000000A7][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerOptions::AddPathMapping([FSharp.Compiler.Service]FSharp.Compiler.CompilerConfig+TcConfigBuilder, string)][offset 0x0000000B][found Char] Unexpected type on the stack. +[IL]: Error [StackUnderflow]: : FSharp.Compiler.CompilerOptions::DoWithColor([System.Console]System.ConsoleColor, [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2)][offset 0x0000005E] Stack underflow. [IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerOptions::parseOption(string)][offset 0x0000000B][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerOptions::getOptionArgList([FSharp.Compiler.Service]FSharp.Compiler.CompilerOptions+CompilerOption, string)][offset 0x00000049][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerOptions::getOptionArgList([FSharp.Compiler.Service]FSharp.Compiler.CompilerOptions+CompilerOption, string)][offset 0x00000052][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerOptions::getSwitch(string)][offset 0x0000000B][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerOptions::attempt([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2, [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1, [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1, [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1, string, string, string, string, [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1)][offset 0x00000A99][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerOptions::processArg([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2, [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1, [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1, [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1)][offset 0x0000003E][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerOptions::AddPathMapping([FSharp.Compiler.Service]FSharp.Compiler.CompilerConfig+TcConfigBuilder, string)][offset 0x0000000B][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerOptions::subSystemVersionSwitch$cont([FSharp.Compiler.Service]FSharp.Compiler.CompilerConfig+TcConfigBuilder, string, [FSharp.Core]Microsoft.FSharp.Core.Unit)][offset 0x0000000B][found Char] Unexpected type on the stack. -[IL]: Error [StackUnderflow]: : FSharp.Compiler.CompilerOptions::DoWithColor([System.Console]System.ConsoleColor, [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2)][offset 0x0000005E] Stack underflow. [IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerOptions+ResponseFile+parseLine::Invoke(string)][offset 0x00000026][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.ParseAndCheckInputs+CheckMultipleInputsUsingGraphMode::Invoke(int32)][offset 0x00000031][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.ParseAndCheckInputs+CheckMultipleInputsUsingGraphMode::Invoke(int32)][offset 0x0000003A][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerImports+TcConfig-TryResolveLibWithDirectories::Invoke([FSharp.Core]Microsoft.FSharp.Core.Unit)][offset 0x00000021][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerImports+TcConfig-TryResolveLibWithDirectories::Invoke([FSharp.Core]Microsoft.FSharp.Core.Unit)][offset 0x0000003B][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerConfig+TcConfig::.ctor([FSharp.Compiler.Service]FSharp.Compiler.CompilerConfig+TcConfigBuilder, bool)][offset 0x00000590][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerConfig+TcConfig::.ctor([FSharp.Compiler.Service]FSharp.Compiler.CompilerConfig+TcConfigBuilder, bool)][offset 0x00000599][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerConfig+TcConfig::.ctor([FSharp.Compiler.Service]FSharp.Compiler.CompilerConfig+TcConfigBuilder, bool)][offset 0x00000596][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerConfig+TcConfig::.ctor([FSharp.Compiler.Service]FSharp.Compiler.CompilerConfig+TcConfigBuilder, bool)][offset 0x0000059F][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.IlxGen::HashRangeSorted([S.P.CoreLib]System.Collections.Generic.IDictionary`2>)][offset 0x00000011][found ref '[FSharp.Compiler.Service]FSharp.Compiler.IlxGen+HashRangeSorted'][expected ref '[FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,int32>'] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.IlxGen::HashRangeSorted([S.P.CoreLib]System.Collections.Generic.IDictionary`2>)][offset 0x00000012][found ref '[FSharp.Compiler.Service]FSharp.Compiler.IlxGen+HashRangeSorted'][expected ref '[FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,T0>'] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.PatternMatchCompilation::isProblematicClause([FSharp.Compiler.Service]FSharp.Compiler.PatternMatchCompilation+MatchClause)][offset 0x00000040][found Byte] Unexpected type on the stack. @@ -95,8 +95,8 @@ [IL]: Error [StackUnexpected]: : FSharp.Compiler.AbstractIL.ILBinaryReader::seekReadNestedRowUncached([FSharp.Core]Microsoft.FSharp.Core.FSharpRef`1>, int32)][offset 0x00000038][found Byte] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.AbstractIL.ILBinaryReader::seekReadNestedRowUncached([FSharp.Core]Microsoft.FSharp.Core.FSharpRef`1>, int32)][offset 0x00000058][found Byte] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.AbstractIL.ILBinaryReader::seekReadGenericParamConstraintIdx([FSharp.Compiler.Service]FSharp.Compiler.AbstractIL.ILBinaryReader+ILMetadataReader, [FSharp.Compiler.Service]FSharp.Compiler.IO.ReadOnlyByteMemory, int32)][offset 0x00000025][found Byte] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : FSharp.Compiler.AbstractIL.ILBinaryReader::rowKindSize$cont(bool, bool, bool, bool[], bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1, [FSharp.Core]Microsoft.FSharp.Core.Unit)][offset 0x000000E5][found Byte] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.AbstractIL.ILBinaryReader::openMetadataReader(string, [FSharp.Compiler.Service]FSharp.Compiler.AbstractIL.ILBinaryReader+BinaryFile, int32, [S.P.CoreLib]System.Tuple`8,bool,bool,bool,bool,bool,System.Tuple`5,bool,int32,int32,int32>>, [FSharp.Compiler.Service]FSharp.Compiler.AbstractIL.ILBinaryReader+PEReader, [FSharp.Compiler.Service]FSharp.Compiler.IO.ReadOnlyByteMemory, [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1, bool)][offset 0x000006B6][found Boolean] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : FSharp.Compiler.AbstractIL.ILBinaryReader::rowKindSize$cont(bool, bool, bool, bool[], bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1, [FSharp.Core]Microsoft.FSharp.Core.Unit)][offset 0x000000E5][found Byte] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.AbstractIL.ILBinaryReader+seekReadInterfaceImpls::Invoke(int32)][offset 0x0000002F][found Byte] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.AbstractIL.ILBinaryReader+seekReadGenericParamConstraints::Invoke(int32)][offset 0x0000002F][found Byte] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.AbstractIL.ILBinaryReader+enclIdx::Invoke(int32)][offset 0x0000002F][found Byte] Unexpected type on the stack. diff --git a/tests/fsharpqa/Source/CompilerOptions/fsi/help/help40-nologo.437.1033.bsl b/tests/fsharpqa/Source/CompilerOptions/fsi/help/help40-nologo.437.1033.bsl index 7d5d9c0e8f..594735ecdf 100644 --- a/tests/fsharpqa/Source/CompilerOptions/fsi/help/help40-nologo.437.1033.bsl +++ b/tests/fsharpqa/Source/CompilerOptions/fsi/help/help40-nologo.437.1033.bsl @@ -65,6 +65,8 @@ Usage: fsiAnyCpu [script.fsx []] language version. --langversion:{version|latest|preview} Specify language version such as 'latest' or 'preview'. +--disableLanguageFeature: Disable a specific language feature + by name. --checked[+|-] Generate overflow checks (off by default) --define: Define conditional compilation diff --git a/tests/fsharpqa/Source/CompilerOptions/fsi/help/help40.437.1033.bsl b/tests/fsharpqa/Source/CompilerOptions/fsi/help/help40.437.1033.bsl index cbf22f98d3..92855ea50f 100644 --- a/tests/fsharpqa/Source/CompilerOptions/fsi/help/help40.437.1033.bsl +++ b/tests/fsharpqa/Source/CompilerOptions/fsi/help/help40.437.1033.bsl @@ -1,4 +1,4 @@ -Microsoft (R) F# Interactive version 13.9.200.0 for F# 9.0 +Microsoft (R) F# Interactive version 15.1.200.0 for F# 10.0 Copyright (c) Microsoft Corporation. All Rights Reserved. Usage: fsiAnyCpu [script.fsx []] @@ -67,6 +67,8 @@ Usage: fsiAnyCpu [script.fsx []] language version. --langversion:{version|latest|preview} Specify language version such as 'latest' or 'preview'. +--disableLanguageFeature: Disable a specific language feature + by name. --checked[+|-] Generate overflow checks (off by default) --define: Define conditional compilation diff --git a/tests/fsharpqa/run.fsharpqa.test.fsx b/tests/fsharpqa/run.fsharpqa.test.fsx index b50736b40c..8618a50e16 100644 --- a/tests/fsharpqa/run.fsharpqa.test.fsx +++ b/tests/fsharpqa/run.fsharpqa.test.fsx @@ -4,7 +4,7 @@ open System.IO open System.Diagnostics -let releaseOrDebug = "Debug" +let releaseOrDebug = "Release" let setEnvVar name value = System.Environment.SetEnvironmentVariable(name, value) @@ -60,4 +60,8 @@ let runPerl arguments = let testResultDir = Path.Combine(rootFolder, "tests", "TestResults") let perlScript = Path.Combine(rootFolder, "tests", "fsharpqa", "testenv", "bin", "runall.pl") -runPerl [|perlScript; "-resultsroot";testResultDir ;"-ttags:gcc"|] \ No newline at end of file + +if not (System.IO.Directory. Exists(testResultDir)) then + System.IO.Directory.CreateDirectory(testResultDir) |> ignore + +runPerl [|perlScript; "-resultsroot";testResultDir ;"-ttags:help"|] \ No newline at end of file