Skip to content

Commit

Permalink
F#8 (#15793)
Browse files Browse the repository at this point in the history
F# 8
  • Loading branch information
vzarytovskii committed Aug 18, 2023
1 parent 5628af4 commit 711de17
Show file tree
Hide file tree
Showing 75 changed files with 384 additions and 633 deletions.
58 changes: 32 additions & 26 deletions src/Compiler/Facilities/LanguageFeatures.fs
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ type LanguageVersion(versionText) =
static let languageVersion50 = 5.0m
static let languageVersion60 = 6.0m
static let languageVersion70 = 7.0m
static let languageVersion80 = 8.0m
static let previewVersion = 9999m // Language version when preview specified
static let defaultVersion = languageVersion70 // Language version when default specified
static let defaultVersion = languageVersion80 // Language version when default specified
static let latestVersion = defaultVersion // Language version when latest specified
static let latestMajorVersion = languageVersion70 // Language version when latestmajor specified
static let latestMajorVersion = languageVersion80 // Language version when latestmajor specified

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

Expand All @@ -104,6 +105,7 @@ type LanguageVersion(versionText) =
languageVersion50
languageVersion60
languageVersion70
languageVersion80
|]

static let features =
Expand Down Expand Up @@ -154,33 +156,35 @@ type LanguageVersion(versionText) =
LanguageFeature.InterfacesWithAbstractStaticMembers, languageVersion70
LanguageFeature.SelfTypeConstraints, languageVersion70

// F# 8.0
LanguageFeature.AccessorFunctionShorthand, languageVersion80
LanguageFeature.MatchNotAllowedForUnionCaseWithNoData, languageVersion80
LanguageFeature.CSharpExtensionAttributeNotRequired, languageVersion80
LanguageFeature.ErrorForNonVirtualMembersOverrides, languageVersion80
LanguageFeature.WarningWhenInliningMethodImplNoInlineMarkedFunction, languageVersion80
LanguageFeature.EscapeDotnetFormattableStrings, languageVersion80
LanguageFeature.ArithmeticInLiterals, languageVersion80
LanguageFeature.ErrorReportingOnStaticClasses, languageVersion80
LanguageFeature.TryWithInSeqExpression, languageVersion80
LanguageFeature.WarningWhenCopyAndUpdateRecordChangesAllFields, languageVersion80
LanguageFeature.StaticMembersInInterfaces, languageVersion80
LanguageFeature.NonInlineLiteralsAsPrintfFormat, languageVersion80
LanguageFeature.NestedCopyAndUpdate, languageVersion80
LanguageFeature.ExtendedStringInterpolation, languageVersion80
LanguageFeature.WarningWhenMultipleRecdTypeChoice, languageVersion80
LanguageFeature.ImprovedImpliedArgumentNames, languageVersion80
LanguageFeature.DiagnosticForObjInference, languageVersion80
LanguageFeature.WarningWhenTailRecAttributeButNonTailRecUsage, languageVersion80
LanguageFeature.StaticLetInRecordsDusEmptyTypes, languageVersion80
LanguageFeature.StrictIndentation, languageVersion80
LanguageFeature.ConstraintIntersectionOnFlexibleTypes, languageVersion80
LanguageFeature.WhileBang, languageVersion80
LanguageFeature.ExtendedFixedBindings, languageVersion80
LanguageFeature.PreferStringGetPinnableReference, languageVersion80

// F# preview
LanguageFeature.FromEndSlicing, previewVersion
LanguageFeature.AccessorFunctionShorthand, previewVersion
LanguageFeature.MatchNotAllowedForUnionCaseWithNoData, previewVersion
LanguageFeature.CSharpExtensionAttributeNotRequired, previewVersion
LanguageFeature.ErrorForNonVirtualMembersOverrides, previewVersion
LanguageFeature.WarningWhenInliningMethodImplNoInlineMarkedFunction, previewVersion
LanguageFeature.EscapeDotnetFormattableStrings, previewVersion
LanguageFeature.ArithmeticInLiterals, previewVersion
LanguageFeature.ErrorReportingOnStaticClasses, previewVersion
LanguageFeature.TryWithInSeqExpression, previewVersion
LanguageFeature.WarningWhenCopyAndUpdateRecordChangesAllFields, previewVersion
LanguageFeature.StaticMembersInInterfaces, previewVersion
LanguageFeature.NonInlineLiteralsAsPrintfFormat, previewVersion
LanguageFeature.NestedCopyAndUpdate, previewVersion
LanguageFeature.ExtendedStringInterpolation, previewVersion
LanguageFeature.WarningWhenMultipleRecdTypeChoice, previewVersion
LanguageFeature.ImprovedImpliedArgumentNames, previewVersion
LanguageFeature.DiagnosticForObjInference, previewVersion
LanguageFeature.WarningWhenTailRecAttributeButNonTailRecUsage, previewVersion
LanguageFeature.StaticLetInRecordsDusEmptyTypes, previewVersion
LanguageFeature.StrictIndentation, previewVersion
LanguageFeature.ConstraintIntersectionOnFlexibleTypes, previewVersion
LanguageFeature.UnmanagedConstraintCsharpInterop, previewVersion
LanguageFeature.WhileBang, previewVersion
LanguageFeature.ExtendedFixedBindings, previewVersion
LanguageFeature.PreferStringGetPinnableReference, previewVersion
]

static let defaultLanguageVersion = LanguageVersion("default")
Expand All @@ -200,6 +204,8 @@ type LanguageVersion(versionText) =
| "6" -> languageVersion60
| "7.0"
| "7" -> languageVersion70
| "8.0"
| "8" -> languageVersion80
| _ -> 0m

let specified = getVersionFromString versionText
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module TestCompilerWarningLevel =
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"warn_level0.fs"|])>]
let ``warn_level0_fs --warn:0`` compilation =
compilation
|> withLangVersionPreview
|> withLangVersion80
|> asExe
|> withOptions ["--warn:0"]
|> compileAndRun
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ module AccessibilityAnnotations_PermittedLocations =
|> shouldFail
|> withDiagnostics [
(Error 531, Line 11, Col 13, Line 11, Col 20, "Accessibility modifiers should come immediately prior to the identifier naming a construct")
(Warning 58, Line 12, Col 23, Line 12, Col 26, "Possible incorrect indentation: this token is offside of context started at position (11:23). Try indenting this token further or using standard formatting conventions.")
(Error 58, Line 12, Col 23, Line 12, Col 26, "Possible incorrect indentation: this token is offside of context started at position (11:23). Try indenting this token further or using standard formatting conventions.")
(Error 531, Line 12, Col 13, Line 12, Col 19, "Accessibility modifiers should come immediately prior to the identifier naming a construct")
(Warning 58, Line 13, Col 23, Line 13, Col 26, "Possible incorrect indentation: this token is offside of context started at position (12:23). Try indenting this token further or using standard formatting conventions.")
(Error 58, Line 13, Col 23, Line 13, Col 26, "Possible incorrect indentation: this token is offside of context started at position (12:23). Try indenting this token further or using standard formatting conventions.")
(Error 531, Line 13, Col 13, Line 13, Col 21, "Accessibility modifiers should come immediately prior to the identifier naming a construct")
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ module LetBindings_Basic =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Warning 58, Line 10, Col 1, Line 10, Col 5, "Possible incorrect indentation: this token is offside of context started at position (8:1). Try indenting this token further or using standard formatting conventions.")
(Error 58, Line 10, Col 1, Line 10, Col 5, "Possible incorrect indentation: this token is offside of context started at position (8:1). Try indenting this token further or using standard formatting conventions.")
(Error 10, Line 10, Col 6, Line 10, Col 7, "Unexpected start of structured construct in expression")
(Error 583, Line 9, Col 5, Line 9, Col 6, "Unmatched '('")
(Error 10, Line 10, Col 16, Line 10, Col 17, "Unexpected symbol ')' in implementation file")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ let ``Should fail in F# 7 and lower`` (implFileName:string) =

[<Theory>]
[<InlineData("7.0")>]
[<InlineData("8.0")>]
[<InlineData("preview")>]
let ``Regression in Member val - not allowed without primary constructor`` (langVersion:string) =
Fs """module Test
Expand All @@ -40,6 +41,7 @@ type Bad3 =

[<Theory>]
[<InlineData("7.0")>]
[<InlineData("8.0")>]
[<InlineData("preview")>]
let ``Regression - Type augmentation with abstract slot not allowed`` (langVersion:string) =
Fs """module Test
Expand All @@ -53,6 +55,7 @@ type System.Random with

[<Theory>]
[<InlineData("7.0")>]
[<InlineData("8.0")>]
[<InlineData("preview")>]
let ``Regression - record with abstract slot not allowed`` (langVersion:string) =
Fs """module Test
Expand All @@ -65,7 +68,7 @@ type myRecord2 = { field1: int; field2: string }

let verifyCompileAndRun compilation =
compilation
|> withLangVersionPreview
|> withLangVersion80
|> asExe
|> compileAndRun

Expand Down Expand Up @@ -95,7 +98,7 @@ init R 2
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"LowercaseDuTest.fs"|])>]
let ``Static let - lowercase DU`` compilation =
compilation
|> withLangVersionPreview
|> withLangVersion80
|> typecheck
|> shouldSucceed

Expand Down Expand Up @@ -127,7 +130,7 @@ let ``Static let in simple union`` compilation =
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"PlainEnum.fs"|])>]
let ``Support in plain enums - typecheck should fail`` compilation =
compilation
|> withLangVersionPreview
|> withLangVersion80
|> typecheck
|> shouldFail
|> withDiagnosticMessage "Enumerations cannot have members"
Expand Down Expand Up @@ -274,7 +277,7 @@ Creating cached val for Uri
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"StaticLetInGenericRecordsILtest.fs"|])>]
let ``Static let record - generics - IL test`` compilation =
compilation
|> withLangVersionPreview
|> withLangVersion80
|> compile
|> verifyIL [""" .method private specialname rtspecialname static
void .cctor() cil managed
Expand Down Expand Up @@ -389,7 +392,7 @@ type X =
static do Console.WriteLine("from type")
do Console.WriteLine("module after type")
"""
|> withLangVersionPreview
|> withLangVersion80
|> compile
|> shouldSucceed
|> verifyIL ["""
Expand Down Expand Up @@ -464,7 +467,7 @@ Console.Write(MyTypes.X.GetX)

FSharp types
|> withAdditionalSourceFiles [SourceCodeFileKind.Create("program.fs", program)]
|> withLangVersionPreview
|> withLangVersion80
|> compile
|> shouldSucceed
|> verifyIL ["""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type ByItsOwnNatureUnBottledAttribute = Microsoft.FSharp.Core.AutoOpenAttribute
module Foo =
let bar = 0
"""
|> withLangVersionPreview
|> withLangVersion80
|> compile
|> shouldFail
|> withDiagnostics [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ let _ = Test<MyDu<int,MyDu<int,string voption>>>()
open CsLib
let y = new CsharpStruct<struct(int*string)>(struct(1,"this is string"))
""" |> withReferences [csLib]
|> withLangVersionPreview
|> withLangVersion80

app
|> compile
Expand Down Expand Up @@ -449,7 +449,7 @@ printf "%s" (CsharpStruct<int>.Hi<MultiCaseUnion>())
""" |> withReferences [csLib]

app
|> withLangVersionPreview
|> withLangVersion80
|> asExe
|> compile
|> run
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ module A
|> typecheck
|> shouldFail
|> withResult {
Error = Warning 58
Error = Error 58
Range = { StartLine = 4
StartColumn = 5
EndLine = 4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module RecordTypes =
let verifyTypeCheckAsFsxAsLibrary compilation =
compilation
|> asLibrary
|> withOptions ["--nowarn:3560"]
|> typecheck
|> shouldSucceed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,9 @@ module UnionTypes =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Warning 58, Line 9, Col 1, Line 9, Col 2, "Possible incorrect indentation: this token is offside of context started at position (8:19). Try indenting this token further or using standard formatting conventions.")
(Error 58, Line 9, Col 1, Line 9, Col 2, "Possible incorrect indentation: this token is offside of context started at position (8:19). Try indenting this token further or using standard formatting conventions.")
(Error 547, Line 8, Col 24, Line 8, Col 33, "A type definition requires one or more members or other declarations. If you intend to define an empty class, struct or interface, then use 'type ... = class end', 'interface end' or 'struct end'.")
(Error 10, Line 9, Col 1, Line 9, Col 2, "Unexpected symbol '|' in implementation file")
]

//SOURCE=W_UnionCaseProduction01.fsx SCFLAGS="-a --test:ErrorRanges" # W_UnionCaseProduction01.fsx
Expand All @@ -607,4 +609,3 @@ module UnionTypes =
|> withDiagnostics [
(Warning 42, Line 11, Col 12, Line 11, Col 24, "This construct is deprecated: it is only for use in the F# library")
]

Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ let x = deserialize "" |> f""", 3, 9, 3, 28
FSharp code
|> withErrorRanges
|> withWarnOn 3559
|> withLangVersionPreview
|> withLangVersion80
|> typecheck
|> shouldFail
|> withSingleDiagnostic (Information 3559, Line line1, Col col1, Line line2, Col col2, message)
Expand Down Expand Up @@ -76,7 +76,7 @@ let f () = x = x |> ignore""" // measure is inferred as 1, but that's not covere
let ``Warning does not fire unless required``(code: string) =
FSharp code
|> withWarnOn 3559
|> withLangVersionPreview
|> withLangVersion80
|> typecheck
|> shouldSucceed

Expand All @@ -93,7 +93,7 @@ let f () = x = x |> ignore""" // measure is inferred as 1, but that's not covere
sprintf "%s |> ignore" expr
|> FSharp
|> withWarnOn 3559
|> withLangVersionPreview
|> withLangVersion80
|> typecheck
|> shouldSucceed

Expand All @@ -103,7 +103,7 @@ let f () = x = x |> ignore""" // measure is inferred as 1, but that's not covere
sprintf "<@ %s @> |> ignore" expr
|> FSharp
|> withWarnOn 3559
|> withLangVersionPreview
|> withLangVersion80
|> typecheck
|> shouldSucceed

Expand All @@ -113,7 +113,7 @@ let f () = x = x |> ignore""" // measure is inferred as 1, but that's not covere
sprintf "<@ %s @> |> ignore" expr
|> FSharp
|> withWarnOn 3559
|> withLangVersionPreview
|> withLangVersion80
|> typecheck
|> shouldFail
|> withSingleDiagnostic (Information 3559, Line line1, Col (col1 + 3), Line line2, Col (col2 + 3), message)
Expand All @@ -124,7 +124,7 @@ let f () = x = x |> ignore""" // measure is inferred as 1, but that's not covere
sprintf "<@ %s @> |> ignore" expr
|> FSharp
|> withWarnOn 3559
|> withLangVersionPreview
|> withLangVersion80
|> typecheck
|> shouldSucceed

Expand All @@ -133,7 +133,7 @@ let f () = x = x |> ignore""" // measure is inferred as 1, but that's not covere
let ``Warning is off by default``(expr: string, _: int, _: int, _: int, _: int) =
expr
|> FSharp
|> withLangVersionPreview
|> withLangVersion80
|> withOptions ["--warnaserror"]
|> typecheck
|> shouldSucceed
6 changes: 3 additions & 3 deletions tests/FSharp.Compiler.ComponentTests/Diagnostics/Records.fs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type R = { F1: int; F2: string }
let updateOk r = { r with F1 = 1 }
let updateWarn r = { r with F1 = 1; F2 = "" }
"""
|> withLangVersionPreview
|> withLangVersion80
|> typecheck
|> shouldFail
|> withDiagnostics [
Expand Down Expand Up @@ -45,7 +45,7 @@ type R = { F1: int; F2: string }
let updateWarn r = { r with F1 = 1; F2 = "" }
"""
|> withLangVersionPreview
|> withLangVersion80
|> withOptions ["--nowarn:3560"]
|> typecheck
|> shouldSucceed
Expand Down Expand Up @@ -85,7 +85,7 @@ let t2 (x: RecTy) (a: AnotherNestedRecTy) = { x with D.C.c = { a with A = 3 } }
// vvvvvvvvvvvvvvvvvvvvvvv
let t3 (x: RecTy) (a: AnotherNestedRecTy) = { x with D.C.c = { a with A = 3; B = 4 } }
"""
|> withLangVersionPreview
|> withLangVersion80
|> typecheck
|> shouldFail
|> withDiagnostics [
Expand Down
10 changes: 5 additions & 5 deletions tests/FSharp.Compiler.ComponentTests/EmittedIL/ArgumentNames.fs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type M (name: string, count: int) =
let test1 = M
let test2 = M.Open
"""
|> withLangVersionPreview
|> withLangVersion80
|> compile
|> shouldSucceed
|> verifyIL ["""
Expand Down Expand Up @@ -56,7 +56,7 @@ type M =
let test1 = M.Write
"""
|> withLangVersionPreview
|> withLangVersion80
|> compile
|> shouldSucceed
|> verifyIL ["""
Expand Down Expand Up @@ -91,7 +91,7 @@ type Ext =
let test1 = (3).Print
"""
|> withLangVersionPreview
|> withLangVersion80
|> compile
|> shouldSucceed
|> verifyIL ["""
Expand Down Expand Up @@ -120,7 +120,7 @@ type DU =
let test1 = X
let test2 = Case1
"""
|> withLangVersionPreview
|> withLangVersion80
|> compile
|> shouldSucceed
|> verifyIL ["""
Expand Down Expand Up @@ -160,7 +160,7 @@ let add num1 num2 = printfn "%d" (num1 + num2)
let test1 = System.Action<_, _>(add)
"""
|> withLangVersionPreview
|> withLangVersion80
|> compile
|> shouldSucceed
|> verifyIL ["""
Expand Down

0 comments on commit 711de17

Please sign in to comment.