Skip to content

Commit

Permalink
Enable F# 9.0 (dotnet#17500)
Browse files Browse the repository at this point in the history
* initial

* Update DefaultAugmentationAttribute

* readme

* readme

* further

* temp

* Update src/Compiler/Facilities/LanguageFeatures.fs

Co-authored-by: Brian Rourke Boll <[email protected]>

* more

* fantomas

* revert EnforceAttributeTargets

* revert

* moar

---------

Co-authored-by: Vlad Zarytovskii <[email protected]>
Co-authored-by: Brian Rourke Boll <[email protected]>
  • Loading branch information
3 people authored Aug 9, 2024
1 parent 9125cb5 commit 4324c4f
Show file tree
Hide file tree
Showing 81 changed files with 899 additions and 1,037 deletions.
2 changes: 1 addition & 1 deletion docs/release-notes/.FSharp.Compiler.Service/9.0.100.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
* Optimize metadata reading for type members and custom attributes. ([PR #17364](https://github.com/dotnet/fsharp/pull/17364))
* Enforce `AttributeTargets` on unions. ([PR #17389](https://github.com/dotnet/fsharp/pull/17389))
* Ensure that isinteractive multi-emit backing fields are not public. ([Issue #17439](https://github.com/dotnet/fsharp/issues/17438)), ([PR #17439](https://github.com/dotnet/fsharp/pull/17439))

* Enable FSharp 9.0 Language Version ([Issue #17497](https://github.com/dotnet/fsharp/issues/17438)), [PR](https://github.com/dotnet/fsharp/pull/17500)))
### Breaking Changes
2 changes: 2 additions & 0 deletions docs/release-notes/.FSharp.Core/9.0.100.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
### Fixed
* Struct UnionCase doesn't seem to be a valid target for the DefaultAugmentationAttribute ([Issue #17499](https://github.com/dotnet/fsharp/issues/17499), [PR #17502](https://github.com/dotnet/fsharp/pull/17502))

### Added

Expand All @@ -8,6 +9,7 @@
### Changed
* Change compiler default setting realsig+ when building assemblies ([Issue #17384](https://github.com/dotnet/fsharp/issues/17384), [PR #17378](https://github.com/dotnet/fsharp/pull/17385))
* Change compiler default setting for compressedMetadata ([Issue #17379](https://github.com/dotnet/fsharp/issues/17379), [PR #17383](https://github.com/dotnet/fsharp/pull/17383))
* Enable FSharp 9.0 Language Version ([Issue #17497](https://github.com/dotnet/fsharp/issues/17438)), [PR](https://github.com/dotnet/fsharp/pull/17500)))
* Struct UnionCase doesn't seem to be a valid target for the DefaultAugmentationAttribute ([Issue #17499](https://github.com/dotnet/fsharp/issues/17499), [PR #17502](https://github.com/dotnet/fsharp/pull/17502))
### Breaking Changes

2 changes: 2 additions & 0 deletions docs/release-notes/.Language/9.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@

### Added

### Changed
* Enable FSharp 9.0 Language Version ([Issue #17497](https://github.com/dotnet/fsharp/issues/17438)), [PR](https://github.com/dotnet/fsharp/pull/17500)))
1 change: 1 addition & 0 deletions docs/release-notes/.VisualStudio/17.12.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
### Changed

### Breaking Changes
* Enable FSharp 9.0 Language Version ([Issue #17497](https://github.com/dotnet/fsharp/issues/17438)), [PR](https://github.com/dotnet/fsharp/pull/17500)))
40 changes: 23 additions & 17 deletions src/Compiler/Facilities/LanguageFeatures.fs
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,11 @@ type LanguageVersion(versionText) =
static let languageVersion60 = 6.0m
static let languageVersion70 = 7.0m
static let languageVersion80 = 8.0m
static let languageVersion90 = 9.0m
static let previewVersion = 9999m // Language version when preview specified
static let defaultVersion = languageVersion80 // Language version when default specified
static let defaultVersion = languageVersion90 // Language version when default specified
static let latestVersion = defaultVersion // Language version when latest specified
static let latestMajorVersion = languageVersion80 // Language version when latestmajor specified
static let latestMajorVersion = languageVersion90 // Language version when latestmajor specified

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

Expand All @@ -119,6 +120,7 @@ type LanguageVersion(versionText) =
languageVersion60
languageVersion70
languageVersion80
languageVersion90
|]

static let features =
Expand Down Expand Up @@ -195,22 +197,24 @@ type LanguageVersion(versionText) =
LanguageFeature.ExtendedFixedBindings, languageVersion80
LanguageFeature.PreferStringGetPinnableReference, languageVersion80

// F# 9.0
LanguageFeature.NullnessChecking, languageVersion90
LanguageFeature.ReuseSameFieldsInStructUnions, languageVersion90
LanguageFeature.PreferExtensionMethodOverPlainProperty, languageVersion90
LanguageFeature.WarningIndexedPropertiesGetSetSameType, languageVersion90
LanguageFeature.WarningWhenTailCallAttrOnNonRec, languageVersion90
LanguageFeature.UnionIsPropertiesVisible, languageVersion90
LanguageFeature.BooleanReturningAndReturnTypeDirectedPartialActivePattern, languageVersion90
LanguageFeature.LowerInterpolatedStringToConcat, languageVersion90
LanguageFeature.LowerIntegralRangesToFastLoops, languageVersion90
LanguageFeature.LowerSimpleMappingsInComprehensionsToFastLoops, languageVersion90
LanguageFeature.ParsedHashDirectiveArgumentNonQuotes, languageVersion90
LanguageFeature.EmptyBodiedComputationExpressions, languageVersion90

// F# preview
LanguageFeature.NullnessChecking, previewVersion
LanguageFeature.FromEndSlicing, previewVersion
LanguageFeature.UnmanagedConstraintCsharpInterop, previewVersion
LanguageFeature.ReuseSameFieldsInStructUnions, previewVersion
LanguageFeature.PreferExtensionMethodOverPlainProperty, previewVersion
LanguageFeature.WarningIndexedPropertiesGetSetSameType, previewVersion
LanguageFeature.WarningWhenTailCallAttrOnNonRec, previewVersion
LanguageFeature.UnionIsPropertiesVisible, previewVersion
LanguageFeature.BooleanReturningAndReturnTypeDirectedPartialActivePattern, previewVersion
LanguageFeature.EnforceAttributeTargets, previewVersion
LanguageFeature.LowerInterpolatedStringToConcat, previewVersion
LanguageFeature.LowerIntegralRangesToFastLoops, previewVersion
LanguageFeature.LowerSimpleMappingsInComprehensionsToFastLoops, previewVersion
LanguageFeature.ParsedHashDirectiveArgumentNonQuotes, previewVersion
LanguageFeature.EmptyBodiedComputationExpressions, previewVersion
LanguageFeature.UnmanagedConstraintCsharpInterop, previewVersion // not enabled because: https://github.com/dotnet/fsharp/issues/17509
LanguageFeature.EnforceAttributeTargets, previewVersion // not enabled because: https://github.com/dotnet/fsharp/issues/17514
LanguageFeature.FromEndSlicing, previewVersion // Unfinished features --- needs work
]

static let defaultLanguageVersion = LanguageVersion("default")
Expand All @@ -232,6 +236,8 @@ type LanguageVersion(versionText) =
| "7" -> languageVersion70
| "8.0"
| "8" -> languageVersion80
| "9.0"
| "9" -> languageVersion90
| _ -> 0m

let specified = getVersionFromString versionText
Expand Down
26 changes: 0 additions & 26 deletions src/FSharp.Core/array.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -3443,7 +3443,6 @@ module Array =
/// </code>
/// </example>
[<CompiledName("ForAll")>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val forall: predicate: ('T -> bool) -> array: 'T array -> bool

/// <summary>Tests if any element of the array satisfies the given predicate.</summary>
Expand Down Expand Up @@ -3477,7 +3476,6 @@ module Array =
/// Evaluates to <c>false</c>
/// </example>
[<CompiledName("Exists")>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val exists: predicate: ('T -> bool) -> array: 'T array -> bool

/// <summary>Returns the first element for which the given function returns <c>True</c>.
Expand Down Expand Up @@ -3508,7 +3506,6 @@ module Array =
/// Evaluates to <c>None</c>
/// </example>
[<CompiledName("TryFind")>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val tryFind: predicate: ('T -> bool) -> array: 'T array -> 'T option

/// <summary>Returns the index of the first element in the array
Expand Down Expand Up @@ -3539,7 +3536,6 @@ module Array =
/// Evaluates to <c>None</c>
/// </example>
[<CompiledName("TryFindIndex")>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val tryFindIndex: predicate: ('T -> bool) -> array: 'T array -> int option

/// <summary>Applies the given function to successive elements, returning the first
Expand Down Expand Up @@ -3572,7 +3568,6 @@ module Array =
/// </example>
///
[<CompiledName("TryPick")>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val tryPick: chooser: ('T -> 'U option) -> array: 'T array -> 'U option

/// <summary>Applies a function to each element of the array in parallel, threading an accumulator argument
Expand Down Expand Up @@ -3600,7 +3595,6 @@ module Array =
/// </example>

[<CompiledName("Reduce")>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val inline reduce: reduction: ('T -> 'T -> 'T) -> array: 'T array -> 'T

/// <summary>Applies a projection function to each element of the array in parallel, reducing elements in each thread with a dedicated 'reduction' function.
Expand Down Expand Up @@ -3628,7 +3622,6 @@ module Array =
/// </example>

[<CompiledName("ReduceBy")>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val reduceBy: projection: ('T -> 'U) -> reduction: ('U -> 'U -> 'U) -> array: 'T array -> 'U

/// <summary>Returns the greatest of all elements of the array, compared via Operators.max.</summary>
Expand Down Expand Up @@ -3660,7 +3653,6 @@ module Array =
/// Throws <c>System.ArgumentException</c>.
/// </example>
[<CompiledName("Max")>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val inline max: array: 'T array -> 'T when 'T: comparison

/// <summary>Returns the greatest of all elements of the array, compared via Operators.max on the function result.</summary>
Expand Down Expand Up @@ -3693,7 +3685,6 @@ module Array =
/// Throws <c>System.ArgumentException</c>.
/// </example>
[<CompiledName("MaxBy")>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val inline maxBy: projection: ('T -> 'U) -> array: 'T array -> 'T when 'U: comparison

/// <summary>Returns the smallest of all elements of the array, compared via Operators.min.</summary>
Expand Down Expand Up @@ -3725,7 +3716,6 @@ module Array =
/// Throws <c>System.ArgumentException</c>.
/// </example>
[<CompiledName("Min")>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val inline min: array: 'T array -> 'T when 'T: comparison

/// <summary>Returns the lowest of all elements of the array, compared via Operators.min on the function result.</summary>
Expand Down Expand Up @@ -3758,7 +3748,6 @@ module Array =
/// Throws <c>System.ArgumentException</c>.
/// </example>
[<CompiledName("MinBy")>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val inline minBy: projection: ('T -> 'U) -> array: 'T array -> 'T when 'U: comparison

/// <summary>Returns the sum of the elements in the array.</summary>
Expand All @@ -3778,7 +3767,6 @@ module Array =
/// Evaluates to <c>11</c>.
/// </example>
[<CompiledName("Sum")>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val inline sum:
array: ^T array -> ^T when ^T: (static member (+): ^T * ^T -> ^T) and ^T: (static member Zero: ^T)

Expand All @@ -3800,7 +3788,6 @@ module Array =
/// Evaluates to <c>7</c>.
/// </example>
[<CompiledName("SumBy")>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val inline sumBy:
projection: ('T -> ^U) -> array: 'T array -> ^U
when ^U: (static member (+): ^U * ^U -> ^U) and ^U: (static member Zero: ^U)
Expand Down Expand Up @@ -3828,7 +3815,6 @@ module Array =
/// Throws <c>ArgumentException</c>
/// </example>
[<CompiledName("Average")>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val inline average:
array: ^T array -> ^T
when ^T: (static member (+): ^T * ^T -> ^T) and ^T: (static member DivideByInt: ^T * int -> ^T)
Expand Down Expand Up @@ -3866,7 +3852,6 @@ module Array =
/// Throws <c>ArgumentException</c>
/// </example>
[<CompiledName("AverageBy")>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val inline averageBy:
projection: ('T -> ^U) -> array: 'T array -> ^U
when ^U: (static member (+): ^U * ^U -> ^U) and ^U: (static member DivideByInt: ^U * int -> ^U)
Expand Down Expand Up @@ -4012,7 +3997,6 @@ module Array =
/// </example>

[<CompiledName("GroupBy")>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val groupBy: projection: ('T -> 'Key) -> array: 'T array -> ('Key * 'T array) array when 'Key: equality

/// <summary>Apply the given function to each element of the array. </summary>
Expand Down Expand Up @@ -4132,7 +4116,6 @@ module Array =
/// Evaluates to <c>[| 1; 1 3; 4; 6; 8 |]</c>.
/// </example>
[<CompiledName("Sort")>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val sort: array: 'T array -> 'T array when 'T: comparison

/// <summary>Sorts the elements of an array in parallel, using the given projection for the keys and returning a new array.
Expand All @@ -4158,7 +4141,6 @@ module Array =
/// </example>

[<CompiledName("SortBy")>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val sortBy: projection: ('T -> 'Key) -> array: 'T array -> 'T array when 'Key: comparison

/// <summary>Sorts the elements of an array in parallel, using the given comparison function as the order, returning a new array.</summary>
Expand Down Expand Up @@ -4187,7 +4169,6 @@ module Array =
/// Evaluates to <c>[|(0, "aa"); (2, "cc"); (3, "dd"); (1, "bbb")|]</c>.
/// </example>
[<CompiledName("SortWith")>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val sortWith: comparer: ('T -> 'T -> int) -> array: 'T array -> 'T array

/// <summary>Sorts the elements of an array by mutating the array in-place in parallel, using the given projection for the keys.
Expand All @@ -4210,7 +4191,6 @@ module Array =
/// After evaluation <c>array</c> contains <c>[|"a"; "dd"; "bbb"; "cccc"|]</c>.
/// </example>
[<CompiledName("SortInPlaceBy")>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val sortInPlaceBy: projection: ('T -> 'Key) -> array: 'T array -> unit when 'Key: comparison

/// <summary>Sorts the elements of an array by mutating the array in-place in parallel, using the given comparison function as the order.</summary>
Expand All @@ -4234,7 +4214,6 @@ module Array =
/// After evaluation <c>array</c> contains <c>[|(0, "aa"); (2, "cc"); (3, "dd"); (1, "bbb")|]</c>.
/// </example>
[<CompiledName("SortInPlaceWith")>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val sortInPlaceWith: comparer: ('T -> 'T -> int) -> array: 'T array -> unit

/// <summary>Sorts the elements of an array by mutating the array in-place in parallel, using the given comparison function.
Expand All @@ -4253,7 +4232,6 @@ module Array =
/// After evaluation <c>array</c> contains <c>[| 1; 1; 3; 4; 6; 8 |]</c>.
/// </example>
[<CompiledName("SortInPlace")>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val sortInPlace: array: 'T array -> unit when 'T: comparison

/// <summary>Sorts the elements of an array in parallel, in descending order, returning a new array. Elements are compared using <see cref="M:Microsoft.FSharp.Core.Operators.compare"/>. </summary>
Expand All @@ -4274,7 +4252,6 @@ module Array =
/// Evaluates to <c>[| 8; 6; 4; 3; 1; 1 |]</c>.
/// </example>
[<CompiledName("SortDescending")>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val sortDescending: array: 'T array -> 'T array when 'T: comparison

/// <summary>Sorts the elements of an array in parallel, in descending order, using the given projection for the keys and returning a new array.
Expand All @@ -4297,7 +4274,6 @@ module Array =
/// Evaluates to <c>[|"cccc"; "bbb"; "dd"; "a"|]</c>.
/// </example>
[<CompiledName("SortByDescending")>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val sortByDescending: projection: ('T -> 'Key) -> array: 'T array -> 'T array when 'Key: comparison

/// <summary>Combines the two arrays into an array of pairs. The two arrays must have equal lengths, otherwise an <c>ArgumentException</c> is
Expand All @@ -4321,7 +4297,6 @@ module Array =
/// Evaluates to <c>[| (1, "one"); (2, "two") |]</c>.
/// </example>
[<CompiledName("Zip")>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val zip: array1: 'T1 array -> array2: 'T2 array -> ('T1 * 'T2) array

/// <summary>Returns a new collection containing only the elements of the collection
Expand All @@ -4343,5 +4318,4 @@ module Array =
/// Evaluates to <c>[| 2; 4 |]</c>
/// </example>
[<CompiledName("Filter")>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val filter: predicate: ('T -> bool) -> array: 'T array -> 'T array
Loading

0 comments on commit 4324c4f

Please sign in to comment.