Skip to content

Move language features from preview to langversion 10 #18708

New issue

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

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

Already on GitHub? Sign in to your account

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
37 changes: 22 additions & 15 deletions src/Compiler/Facilities/LanguageFeatures.fs
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,11 @@ type LanguageVersion(versionText) =
static let languageVersion70 = 7.0m
static let languageVersion80 = 8.0m
static let languageVersion90 = 9.0m
static let languageVersion100 = 10.0m
static let previewVersion = 9999m // Language version when preview specified
static let defaultVersion = languageVersion90 // Language version when default specified
static let defaultVersion = languageVersion100 // Language version when default specified
static let latestVersion = defaultVersion // Language version when latest specified
static let latestMajorVersion = languageVersion90 // Language version when latestmajor specified
static let latestMajorVersion = languageVersion100 // Language version when latestmajor specified

static let validOptions = [| "preview"; "default"; "latest"; "latestmajor" |]

Expand All @@ -132,6 +133,7 @@ type LanguageVersion(versionText) =
languageVersion70
languageVersion80
languageVersion90
languageVersion100
|]

static let features =
Expand Down Expand Up @@ -222,21 +224,24 @@ type LanguageVersion(versionText) =
LanguageFeature.ParsedHashDirectiveArgumentNonQuotes, languageVersion90
LanguageFeature.EmptyBodiedComputationExpressions, languageVersion90

// F# preview
LanguageFeature.EnforceAttributeTargets, previewVersion // Not enabled due to a number of external library dependencies on unenforced attributes
LanguageFeature.UseTypeSubsumptionCache, previewVersion
// F# 10.0
LanguageFeature.EnforceAttributeTargets, languageVersion100
LanguageFeature.UseTypeSubsumptionCache, languageVersion100

LanguageFeature.AllowObjectExpressionWithoutOverrides, languageVersion100
LanguageFeature.DontWarnOnUppercaseIdentifiersInBindingPatterns, languageVersion100
LanguageFeature.DeprecatePlacesWhereSeqCanBeOmitted, languageVersion100
LanguageFeature.SupportValueOptionsAsOptionalParameters, languageVersion100
LanguageFeature.WarnWhenUnitPassedToObjArg, languageVersion100
LanguageFeature.UseBangBindingValueDiscard, languageVersion100
LanguageFeature.BetterAnonymousRecordParsing, languageVersion100
LanguageFeature.ScopedNowarn, languageVersion100
LanguageFeature.AllowTypedLetOrUseBang, languageVersion100

// F# preview (still preview in 10.0)
LanguageFeature.UnmanagedConstraintCsharpInterop, previewVersion // not enabled because: https://github.com/dotnet/fsharp/issues/17509
LanguageFeature.FromEndSlicing, previewVersion // Unfinished features --- needs work
LanguageFeature.AllowAccessModifiersToAutoPropertiesGettersAndSetters, previewVersion
LanguageFeature.AllowObjectExpressionWithoutOverrides, previewVersion
LanguageFeature.DontWarnOnUppercaseIdentifiersInBindingPatterns, previewVersion
LanguageFeature.DeprecatePlacesWhereSeqCanBeOmitted, previewVersion
LanguageFeature.SupportValueOptionsAsOptionalParameters, previewVersion
LanguageFeature.WarnWhenUnitPassedToObjArg, previewVersion
LanguageFeature.UseBangBindingValueDiscard, previewVersion
LanguageFeature.BetterAnonymousRecordParsing, previewVersion
LanguageFeature.ScopedNowarn, previewVersion
LanguageFeature.AllowTypedLetOrUseBang, previewVersion
LanguageFeature.AllowAccessModifiersToAutoPropertiesGettersAndSetters, previewVersion // Stopped printing arguments to indexed properties
]

static let defaultLanguageVersion = LanguageVersion("default")
Expand All @@ -260,6 +265,8 @@ type LanguageVersion(versionText) =
| "8" -> languageVersion80
| "9.0"
| "9" -> languageVersion90
| "10.0"
| "10" -> languageVersion100
| _ -> 0m

let specified = getVersionFromString versionText
Expand Down
44 changes: 44 additions & 0 deletions start-vs-FsharpSln.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
@echo off
setlocal enabledelayedexpansion

:: This command launches a Visual Studio solution with environment variables required to use a local version of the .NET Core SDK.

:: This tells .NET Core to use the same dotnet.exe that build scripts use
set DOTNET_ROOT=%~dp0.dotnet
set DOTNET_ROOT(x86)=%~dp0.dotnet\x86

:: This tells .NET Core not to go looking for .NET Core in other places
set DOTNET_MULTILEVEL_LOOKUP=0

:: Put our local dotnet.exe on PATH first so Visual Studio knows which one to use
set PATH=%DOTNET_ROOT%;%PATH%

call restore.cmd

if not exist "%DOTNET_ROOT%\dotnet.exe" (
echo [ERROR] .NET Core has not yet been installed. Run `%~dp0restore.cmd` to install tools
exit /b 1
)

:: These tasks aren't running successfully when launching VS, skipping when launching via this batch file
set RunNetFrameworkApiCompat=false
set RunRefApiCompat=false

:: Prefer the VS in the developer command prompt if we're in one, followed by whatever shows up in the current search path.
set "DEVENV=%DevEnvDir%devenv.exe"

if exist "%DEVENV%" (
:: Fully qualified works
set "COMMAND=start "" /B "%ComSpec%" /S /C ""%DEVENV%" "%~dp0FSharp.sln"""
) else (
where devenv.exe /Q
if !errorlevel! equ 0 (
:: On the PATH, use that.
set "COMMAND=start "" /B "%ComSpec%" /S /C "devenv.exe "%~dp0FSharp.sln"""
) else (
:: Can't find devenv.exe, let file associations take care of it
set "COMMAND=start /B .\FSharp.sln"
)
)

%COMMAND%
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module Nowarn =
let private make20 = "1"
let private make25 = "match None with None -> ()"
let private W20 = Warning 20
let private vp = "PREVIEW"
let private vp = "LATEST"
let private v9 = "9.0"
let private fs = String.concat Environment.NewLine >> FsSource
let private fsMod lines = fs ("module A" :: lines)
Expand Down Expand Up @@ -179,6 +179,6 @@ let a = 1; #nowarn 20
|> compile
|> withDiagnostics [
Error 3874, Line 4, Col 11, Line 4, Col 22, "#nowarn/#warnon directives must appear as the first non-whitespace characters on a line"
Warning 203, Line 3, Col 9, Line 3, Col 11, "Invalid warning number 'xy'"
Warning 203, Line 3, Col 12, Line 3, Col 17, "Invalid warning number 'abx'"
Error 203, Line 3, Col 9, Line 3, Col 11, "Invalid warning number 'xy'"
Error 203, Line 3, Col 12, Line 3, Col 17, "Invalid warning number 'abx'"
]
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module flaterrors =
|> compile options
|> shouldFail
|> withDiagnostics [
(Warning 3873, Line 1, Col 10, Line 1, Col 17, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
(Error 1, Line 1, Col 11, Line 1, Col 16, "This expression was expected to have type\n ''a list' \nbut here has type\n ''b seq' ")
(Error 1, Line 1, Col 11, Line 1, Col 16, "This expression was expected to have type\n ''a list' \nbut here has type\n 'int seq' ")
(Warning 20, Line 1, Col 1, Line 1, Col 17, "The result of this expression has type ''a list' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'.")
Expand All @@ -40,6 +41,7 @@ module flaterrors =
|> compile options
|> shouldFail
|> withDiagnostics [
(Warning 3873, Line 1, Col 10, Line 1, Col 17, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
(Error 1, Line 1, Col 11, Line 1, Col 16, "This expression was expected to have type\029 ''a list' \029but here has type\029 ''b seq'")
(Error 1, Line 1, Col 11, Line 1, Col 16, "This expression was expected to have type\029 ''a list' \029but here has type\029 'int seq'")
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ module CustomAttributes_AttributeUsage =
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"AttributeTargetsIsMethod01.fs"|])>]
let ``Preview: AttributeTargetsIsMethod01_fs opt-in warning`` compilation =
compilation
|> withLangVersionPreview
|> withWarnOn 3878
|> verifyCompileAndRun
|> shouldSucceed
Expand Down Expand Up @@ -110,7 +109,6 @@ module CustomAttributes_AttributeUsage =
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_AttributeTargets01.fs"|])>]
let ``E_AttributeTargets01_fs`` compilation =
compilation
|> withLangVersionPreview
|> verifyCompile
|> shouldFail
|> withDiagnostics [
Expand Down Expand Up @@ -147,7 +145,6 @@ module CustomAttributes_AttributeUsage =
let ``E_AttributeTargetIsField01_fs`` compilation =
compilation
|> withOptions ["--nowarn:25"]
|> withLangVersionPreview
|> verifyCompile
|> shouldFail
|> withDiagnostics [
Expand Down Expand Up @@ -200,7 +197,6 @@ module CustomAttributes_AttributeUsage =
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_AttributeTargetIsMethod02.fs"|])>]
let ``E_AttributeTargetIsMethod02_fs`` compilation =
compilation
|> withLangVersionPreview
|> withOptions ["--nowarn:25"]
|> verifyCompile
|> shouldFail
Expand Down Expand Up @@ -231,7 +227,6 @@ module CustomAttributes_AttributeUsage =
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_AttributeTargetIsMethod03.fs"|])>]
let ``E_AttributeTargetIsMethod03_fs`` compilation =
compilation
|> withLangVersionPreview
|> withOptions ["--nowarn:25"]
|> verifyCompile
|> shouldFail
Expand Down Expand Up @@ -349,7 +344,6 @@ module CustomAttributes_AttributeUsage =
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_AttributeTargetIsStruct.fs"|])>]
let ``E_AttributeTargetIsStruct_fs`` compilation =
compilation
|> withLangVersionPreview
|> verifyCompile
|> shouldFail
|> withDiagnostics [
Expand Down Expand Up @@ -379,7 +373,6 @@ module CustomAttributes_AttributeUsage =
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_AttributeTargetIsClass.fs"|])>]
let ``E_AttributeTargetIsClass_fs`` compilation =
compilation
|> withLangVersionPreview
|> verifyCompile
|> shouldFail
|> withDiagnostics [
Expand All @@ -400,7 +393,6 @@ module CustomAttributes_AttributeUsage =
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_AttributeTargetIsClass01.fs"|])>]
let ``E_AttributeTargetIsClass01_fs`` compilation =
compilation
|> withLangVersionPreview
|> verifyCompile
|> shouldFail
|> withDiagnostics [
Expand Down Expand Up @@ -510,7 +502,6 @@ module CustomAttributes_AttributeUsage =
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_AttributeTargetIsField03.fs"|])>]
let ``E_AttributeTargetIsField03_fs`` compilation =
compilation
|> withLangVersionPreview
|> verifyCompile
|> shouldFail
|> withDiagnostics [
Expand All @@ -521,7 +512,6 @@ module CustomAttributes_AttributeUsage =
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_AttributeTargetIsField03.fs"|])>]
let ``Preview: E_AttributeTargetIsField03_fs opt-in warning`` compilation =
compilation
|> withLangVersionPreview
|> withWarnOn 3878
|> verifyCompile
|> shouldFail
Expand All @@ -543,7 +533,6 @@ module CustomAttributes_AttributeUsage =
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_AttributeTargetIsProperty01.fs"|])>]
let ``E_AttributeTargetIsProperty01_fs`` compilation =
compilation
|> withLangVersionPreview
|> verifyCompile
|> shouldSucceed

Expand All @@ -559,7 +548,6 @@ module CustomAttributes_AttributeUsage =
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_AttributeTargetIsCtor01.fs"|])>]
let ``E_AttributeTargetIsCtor01_fs`` compilation =
compilation
|> withLangVersionPreview
|> verifyCompile
|> shouldFail
|> withDiagnostics [
Expand Down Expand Up @@ -596,7 +584,6 @@ module CustomAttributes_AttributeUsage =
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_AttributeTargetIsEnum01.fs"|])>]
let ``E_AttributeTargetIsEnum01_fs`` compilation =
compilation
|> withLangVersionPreview
|> verifyCompile
|> shouldFail
|> withDiagnostics [
Expand Down Expand Up @@ -633,7 +620,6 @@ module CustomAttributes_AttributeUsage =
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_AttributeTargetIsDelegate01.fs"|])>]
let ``E_AttributeTargetsIsDelegate01_fs`` compilation =
compilation
|> withLangVersionPreview
|> verifyCompile
|> shouldFail
|> withDiagnostics [
Expand Down Expand Up @@ -682,7 +668,6 @@ type InterruptibleLazy<'T> private (valueFactory: unit -> 'T) =
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_AttributeTargetIsInterface.fs"|])>]
let ``E_AttributeTargetIsInterface_fs`` compilation =
compilation
|> withLangVersionPreview
|> verifyCompile
|> shouldFail
|> withDiagnostics [
Expand All @@ -704,7 +689,6 @@ type InterruptibleLazy<'T> private (valueFactory: unit -> 'T) =
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_AttributeTargetIsClass02.fs"|])>]
let ``E_AttributeTargetIsClass02_fs`` compilation =
compilation
|> withLangVersionPreview
|> verifyCompile
|> shouldFail
|> withDiagnostics [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ module CustomAttributes_Basic =
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_StructLayoutSequentialNeg_DU2.fs"|])>]
let ``E_StructLayoutSequentialNeg_DU2_fs`` compilation =
compilation
|> withLangVersionPreview
|> verifyCompile
|> shouldFail
|> withDiagnostics [
Expand All @@ -171,7 +170,6 @@ module CustomAttributes_Basic =
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_StructLayoutSequentialNeg_Delegate.fs"|])>]
let ``E_StructLayoutSequentialNeg_Delegate_fs`` compilation =
compilation
|> withLangVersionPreview
|> verifyCompile
|> shouldFail
|> withDiagnostics [
Expand All @@ -182,7 +180,6 @@ module CustomAttributes_Basic =
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_StructLayoutSequentialNeg_Interface.fs"|])>]
let ``E_StructLayoutSequentialNeg_Interface_fs`` compilation =
compilation
|> withLangVersionPreview
|> verifyCompile
|> shouldFail
|> withDiagnostics [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ a.Invoke()"""
let f = fun (a: int voption) -> defaultValueArg a 100 |> printf "line: %d"
let a = A f
a.Invoke(5)"""
|> withLangVersionPreview
|> compileExeAndRun
|> shouldSucceed
|> verifyOutput "line: 5"
Loading
Loading