Skip to content

Commit

Permalink
Enable new language features for F# 5.0 (#9827)
Browse files Browse the repository at this point in the history
* Update to fsharp5

* Update preview error messages

* Update error messages

* fix
  • Loading branch information
KevinRansom authored Aug 12, 2020
1 parent 97326c6 commit 9156636
Show file tree
Hide file tree
Showing 23 changed files with 57 additions and 79 deletions.
19 changes: 0 additions & 19 deletions src/fsharp/FSharp.Core/prim-types.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -1328,97 +1328,78 @@ namespace Microsoft.FSharp.Core

/// <summary>A compiler intrinsic that implements dynamic invocations to the '-' operator.</summary>
[<CompilerMessage("This function is for use by dynamic invocations of F# code and should not be used directly", 1204, IsHidden=true)>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val SubtractionDynamic : x:'T1 -> y:'T2 -> 'U

/// <summary>A compiler intrinsic that implements dynamic invocations to the '/' operator.</summary>
[<CompilerMessage("This function is for use by dynamic invocations of F# code and should not be used directly", 1204, IsHidden=true)>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val DivisionDynamic : x:'T1 -> y:'T2 -> 'U

/// <summary>A compiler intrinsic that implements dynamic invocations to the unary '-' operator.</summary>
[<CompilerMessage("This function is for use by dynamic invocations of F# code and should not be used directly", 1204, IsHidden=true)>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val UnaryNegationDynamic : value:'T -> 'U

/// <summary>A compiler intrinsic that implements dynamic invocations to the '%' operator.</summary>
[<CompilerMessage("This function is for use by dynamic invocations of F# code and should not be used directly", 1204, IsHidden=true)>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val ModulusDynamic : x:'T1 -> y:'T2 -> 'U

/// <summary>A compiler intrinsic that implements dynamic invocations to the checked '-' operator.</summary>
[<CompilerMessage("This function is for use by dynamic invocations of F# code and should not be used directly", 1204, IsHidden=true)>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val CheckedSubtractionDynamic : x:'T1 -> y:'T2 -> 'U

/// <summary>A compiler intrinsic that implements dynamic invocations to the checked unary '-' operator.</summary>
[<CompilerMessage("This function is for use by dynamic invocations of F# code and should not be used directly", 1204, IsHidden=true)>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val CheckedUnaryNegationDynamic : value:'T -> 'U

/// <summary>A compiler intrinsic that implements dynamic invocations to the '&lt;&lt;&lt;' operator.</summary>
[<CompilerMessage("This function is for use by dynamic invocations of F# code and should not be used directly", 1204, IsHidden=true)>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val LeftShiftDynamic : value:'T1 -> shift:'T2 -> 'U

/// <summary>A compiler intrinsic that implements dynamic invocations to the '&gt;&gt;&gt;' operator.</summary>
[<CompilerMessage("This function is for use by dynamic invocations of F# code and should not be used directly", 1204, IsHidden=true)>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val RightShiftDynamic : value:'T1 -> shift:'T2 -> 'U

/// <summary>A compiler intrinsic that implements dynamic invocations to the '&amp;&amp;&amp;' operator.</summary>
[<CompilerMessage("This function is for use by dynamic invocations of F# code and should not be used directly", 1204, IsHidden=true)>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val BitwiseAndDynamic : x:'T1 -> y:'T2 -> 'U

/// <summary>A compiler intrinsic that implements dynamic invocations to the '|||' operator.</summary>
[<CompilerMessage("This function is for use by dynamic invocations of F# code and should not be used directly", 1204, IsHidden=true)>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val BitwiseOrDynamic : x:'T1 -> y:'T2 -> 'U

/// <summary>A compiler intrinsic that implements dynamic invocations related to the '^^^' operator.</summary>
[<CompilerMessage("This function is for use by dynamic invocations of F# code and should not be used directly", 1204, IsHidden=true)>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val ExclusiveOrDynamic : x:'T1 -> y:'T2 -> 'U

/// <summary>A compiler intrinsic that implements dynamic invocations related to the '~~~' operator.</summary>
[<CompilerMessage("This function is for use by dynamic invocations of F# code and should not be used directly", 1204, IsHidden=true)>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val LogicalNotDynamic : value:'T -> 'U

/// <summary>A compiler intrinsic that implements dynamic invocations related to conversion operators.</summary>
[<CompilerMessage("This function is for use by dynamic invocations of F# code and should not be used directly", 1204, IsHidden=true)>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val ExplicitDynamic : value:'T -> 'U

/// <summary>A compiler intrinsic that implements dynamic invocations related to the '&lt;' operator.</summary>
[<CompilerMessage("This function is for use by dynamic invocations of F# code and should not be used directly", 1204, IsHidden=true)>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val LessThanDynamic : x:'T1 -> y:'T2 -> 'U

/// <summary>A compiler intrinsic that implements dynamic invocations related to the '&gt;' operator.</summary>
[<CompilerMessage("This function is for use by dynamic invocations of F# code and should not be used directly", 1204, IsHidden=true)>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val GreaterThanDynamic : x:'T1 -> y:'T2 -> 'U

/// <summary>A compiler intrinsic that implements dynamic invocations related to the '&lt;=' operator.</summary>
[<CompilerMessage("This function is for use by dynamic invocations of F# code and should not be used directly", 1204, IsHidden=true)>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val LessThanOrEqualDynamic : x:'T1 -> y:'T2 -> 'U

/// <summary>A compiler intrinsic that implements dynamic invocations related to the '&gt;=' operator.</summary>
[<CompilerMessage("This function is for use by dynamic invocations of F# code and should not be used directly", 1204, IsHidden=true)>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val GreaterThanOrEqualDynamic : x:'T1 -> y:'T2 -> 'U

/// <summary>A compiler intrinsic that implements dynamic invocations related to the '=' operator.</summary>
[<CompilerMessage("This function is for use by dynamic invocations of F# code and should not be used directly", 1204, IsHidden=true)>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val EqualityDynamic : x:'T1 -> y:'T2 -> 'U

/// <summary>A compiler intrinsic that implements dynamic invocations related to the '=' operator.</summary>
[<CompilerMessage("This function is for use by dynamic invocations of F# code and should not be used directly", 1204, IsHidden=true)>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val InequalityDynamic : x:'T1 -> y:'T2 -> 'U

/// <summary>A compiler intrinsic that implements dynamic invocations for the DivideByInt primitive.</summary>
Expand Down
3 changes: 0 additions & 3 deletions src/fsharp/FSharp.Core/quotations.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ type Expr =
/// <param name="arguments">The list of arguments to the method.</param>
///
/// <returns>The resulting expression.</returns>
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
static member CallWithWitnesses: methodInfo: MethodInfo * methodInfoWithWitnesses: MethodInfo * witnesses: Expr list * arguments: Expr list -> Expr

/// <summary>Builds an expression that represents a call to an instance method associated with an object</summary>
Expand All @@ -142,7 +141,6 @@ type Expr =
/// <param name="arguments">The list of arguments to the method.</param>
///
/// <returns>The resulting expression.</returns>
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
static member CallWithWitnesses: obj:Expr * methodInfo:MethodInfo * methodInfoWithWitnesses: MethodInfo * witnesses: Expr list * arguments:Expr list -> Expr

/// <summary>Builds an expression that represents the coercion of an expression to a type</summary>
Expand Down Expand Up @@ -607,7 +605,6 @@ module Patterns =
///
/// <returns>When successful, the pattern binds the object, method, witness-argument and argument sub-expressions of the input expression</returns>
[<CompiledName("CallWithWitnessesPattern")>]
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val (|CallWithWitnesses|_|) : input:Expr -> (Expr option * MethodInfo * MethodInfo * Expr list * Expr list) option

/// <summary>An active pattern to recognize expressions that represent coercions from one type to another</summary>
Expand Down
10 changes: 5 additions & 5 deletions src/fsharp/LanguageFeatures.fs
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ type LanguageVersion (specifiedVersionAsString) =
LanguageFeature.AndBang, languageVersion50
LanguageFeature.NullableOptionalInterop, languageVersion50
LanguageFeature.DefaultInterfaceMemberConsumption, languageVersion50
LanguageFeature.OpenStaticClasses, languageVersion50
LanguageFeature.PackageManagement, languageVersion50
LanguageFeature.WitnessPassing, languageVersion50
LanguageFeature.InterfacesWithMultipleGenericInstantiation, languageVersion50
LanguageFeature.NameOf, languageVersion50

// F# preview
LanguageFeature.FromEndSlicing, previewVersion
LanguageFeature.OpenStaticClasses, previewVersion
LanguageFeature.PackageManagement, previewVersion
LanguageFeature.WitnessPassing, previewVersion
LanguageFeature.InterfacesWithMultipleGenericInstantiation, previewVersion
LanguageFeature.NameOf, previewVersion
LanguageFeature.StringInterpolation, previewVersion
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ module ``Numeric Literals`` =
[<Fact>]
let ``1N is invalid numeric literal in FSI``() =
if Utils.runningOnMono then ()
else
CompilerAssert.RunScriptWithOptions [| "--langversion:preview"; "--test:ErrorRanges" |]
else
CompilerAssert.RunScriptWithOptions [| "--langversion:5.0"; "--test:ErrorRanges" |]
"""
let x = 1N
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ let z : unit =
failwithf "did not expect expression for 'z': %A" e
"""
|> asExe
|> withPreview
|> withOptions ["--langversion:5.0"]
|> compileAndRun
|> shouldSucceed
4 changes: 2 additions & 2 deletions tests/fsharp/Compiler/Language/InterfaceTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ assertion (fun (x:float) -> x * 3.0) (fun v ->
``Many Instantiations of the same interface - Asserts``,
Fs, Library,
options = [|
"--langversion:preview";
"--langversion:5.0";
#if !NETSTANDARD
|])
#else
Expand All @@ -203,7 +203,7 @@ assertion (fun (x:float) -> x * 3.0) (fun v ->
|]
``Many Instantiations of the same interface``
[|
(FSharpErrorSeverity.Error, 3350, (24, 6, 24, 20), "Feature 'interfaces with multiple generic instantiation' is not available in F# 4.7. Please use language version 'preview' or greater.")
(FSharpErrorSeverity.Error, 3350, (24, 6, 24, 20), "Feature 'interfaces with multiple generic instantiation' is not available in F# 4.7. Please use language version 5.0 or greater.")
|]

[<Test>]
Expand Down
12 changes: 6 additions & 6 deletions tests/fsharp/Compiler/Language/OpenStaticClasses.fs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ module OpenSystemMathOnce =
[<Test>]
let ``OpenStaticClassesTests - OpenSystemMathOnce - langversion:preview`` () =
CompilerAssert.TypeCheckWithErrorsAndOptions
[| "--langversion:preview" |]
[| "--langversion:5.0" |]
(baseModule + """
module OpenSystemMathOnce =
Expand Down Expand Up @@ -82,7 +82,7 @@ module OpenSystemMathTwice =
[<Test>]
let ``OpenStaticClassesTests - OpenSystemMathTwice - langversion:preview`` () =
CompilerAssert.TypeCheckWithErrorsAndOptions
[| "--langversion:preview" |]
[| "--langversion:5.0" |]
(baseModule + """
module OpenSystemMathOnce =
Expand All @@ -109,7 +109,7 @@ module OpenMyMathOnce =
[<Test>]
let ``OpenStaticClassesTests - OpenMyMathOnce - langversion:preview`` () =
CompilerAssert.TypeCheckWithErrorsAndOptions
[| "--langversion:preview" |]
[| "--langversion:5.0" |]
(baseModule + """
module OpenMyMathOnce =
Expand All @@ -135,7 +135,7 @@ module DontOpenAutoMath =
[<Test>]
let ``OpenStaticClassesTests - DontOpenAutoMath - langversion:preview`` () =
CompilerAssert.TypeCheckWithErrorsAndOptions
[| "--langversion:preview" |]
[| "--langversion:5.0" |]
(baseModule + """
module DontOpenAutoMath =
Expand Down Expand Up @@ -163,7 +163,7 @@ module OpenAutoMath =
[<Test>]
let ``OpenStaticClassesTests - OpenAutoMath - langversion:preview`` () =
CompilerAssert.TypeCheckWithErrorsAndOptions
[| "--langversion:preview" |]
[| "--langversion:5.0" |]
(baseModule + """
module OpenAutoMath =
open AutoOpenMyMath
Expand All @@ -176,7 +176,7 @@ module OpenAutoMath =
[<Test>]
let ``OpenStaticClassesTests - OpenAccessibleFields - langversion:preview`` () =
CompilerAssert.TypeCheckWithErrorsAndOptions
[| "--langversion:preview" |]
[| "--langversion:5.0" |]
(baseModule + """
module OpenAFieldFromMath =
open System.Math
Expand Down
2 changes: 1 addition & 1 deletion tests/fsharp/Compiler/Language/WitnessTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module WitnessTests =
""" (dir ++ "provider.fsx"))
|> asExe
|> ignoreWarnings
|> withPreview
|> withOptions ["--langversion:5.0"]
|> compile
|> shouldSucceed
|> ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module ``Comparison Tests`` =
// Regression test for FSHARP1.0:5640
// This is a sanity test: more coverage in FSHARP suite...

CompilerAssert.RunScriptWithOptions [| "--langversion:preview" |]
CompilerAssert.RunScriptWithOptions [| "--langversion:5.0" |]
"""
type 'a www = W of 'a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ module ``String Format Tests`` =
let ``string constructor in FSI``() =
// Regression test for FSHARP1.0:5894

CompilerAssert.RunScriptWithOptions [| "--langversion:preview" |]
CompilerAssert.RunScriptWithOptions [| "--langversion:5.0" |]
"""
let assertEqual a b =
if a <> b then failwithf "Expected '%s', but got '%s'" a b
Expand Down
10 changes: 5 additions & 5 deletions tests/fsharp/tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -875,31 +875,31 @@ module CoreTests =

[<Test>]
let ``printing-1 --langversion:5.0`` () =
printing "--langversion:preview" "z.output.test.default.stdout.50.txt" "z.output.test.default.stdout.50.bsl" "z.output.test.default.stderr.txt" "z.output.test.default.stderr.bsl"
printing "--langversion:5.0" "z.output.test.default.stdout.50.txt" "z.output.test.default.stdout.50.bsl" "z.output.test.default.stderr.txt" "z.output.test.default.stderr.bsl"

[<Test>]
let ``printing-2 --langversion:4.7`` () =
printing "--langversion:4.7 --use:preludePrintSize1000.fsx" "z.output.test.1000.stdout.47.txt" "z.output.test.1000.stdout.47.bsl" "z.output.test.1000.stderr.txt" "z.output.test.1000.stderr.bsl"

[<Test>]
let ``printing-2 --langversion:5.0`` () =
printing "--langversion:preview --use:preludePrintSize1000.fsx" "z.output.test.1000.stdout.50.txt" "z.output.test.1000.stdout.50.bsl" "z.output.test.1000.stderr.txt" "z.output.test.1000.stderr.bsl"
printing "--langversion:5.0 --use:preludePrintSize1000.fsx" "z.output.test.1000.stdout.50.txt" "z.output.test.1000.stdout.50.bsl" "z.output.test.1000.stderr.txt" "z.output.test.1000.stderr.bsl"

[<Test>]
let ``printing-3 --langversion:4.7`` () =
printing "--langversion:4.7 --use:preludePrintSize200.fsx" "z.output.test.200.stdout.47.txt" "z.output.test.200.stdout.47.bsl" "z.output.test.200.stderr.txt" "z.output.test.200.stderr.bsl"

[<Test>]
let ``printing-3 --langversion:5.0`` () =
printing "--langversion:preview --use:preludePrintSize200.fsx" "z.output.test.200.stdout.50.txt" "z.output.test.200.stdout.50.bsl" "z.output.test.200.stderr.txt" "z.output.test.200.stderr.bsl"
printing "--langversion:5.0 --use:preludePrintSize200.fsx" "z.output.test.200.stdout.50.txt" "z.output.test.200.stdout.50.bsl" "z.output.test.200.stderr.txt" "z.output.test.200.stderr.bsl"

[<Test>]
let ``printing-4 --langversion:4.7`` () =
printing "--langversion:4.7 --use:preludeShowDeclarationValuesFalse.fsx" "z.output.test.off.stdout.47.txt" "z.output.test.off.stdout.47.bsl" "z.output.test.off.stderr.txt" "z.output.test.off.stderr.bsl"

[<Test>]
let ``printing-4 --langversion:5.0`` () =
printing "--langversion:preview --use:preludeShowDeclarationValuesFalse.fsx" "z.output.test.off.stdout.50.txt" "z.output.test.off.stdout.50.bsl" "z.output.test.off.stderr.txt" "z.output.test.off.stderr.bsl"
printing "--langversion:5.0 --use:preludeShowDeclarationValuesFalse.fsx" "z.output.test.off.stdout.50.txt" "z.output.test.off.stdout.50.bsl" "z.output.test.off.stderr.txt" "z.output.test.off.stderr.bsl"

[<Test>]
let ``printing-5`` () =
Expand Down Expand Up @@ -997,7 +997,7 @@ module CoreTests =

csc cfg """/nologo /target:library /out:cslib.dll""" ["cslib.cs"]

fsc cfg "%s --define:LANGVERSION_PREVIEW --langversion:preview -o:test.exe -r cslib.dll -g" cfg.fsc_flags ["test.fsx"]
fsc cfg "%s --define:LANGVERSION_PREVIEW --langversion:5.0 -o:test.exe -r cslib.dll -g" cfg.fsc_flags ["test.fsx"]

peverify cfg "test.exe"

Expand Down
Loading

0 comments on commit 9156636

Please sign in to comment.