Skip to content
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

Merge main to release/dev17.8 #15792

Merged
merged 4 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions FSharp.Editor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.VS.FSI", "vsintegrat
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FSharp.Editor.IntegrationTests", "vsintegration\tests\FSharp.Editor.IntegrationTests\FSharp.Editor.IntegrationTests.csproj", "{42BE0F2F-BC45-437B-851D-E88A83201339}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Test.Utilities", "tests\FSharp.Test.Utilities\FSharp.Test.Utilities.fsproj", "{B7148170-93C5-4F2F-B31D-85316D3248CF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -73,6 +75,12 @@ Global
{42BE0F2F-BC45-437B-851D-E88A83201339}.Proto|Any CPU.Build.0 = Debug|Any CPU
{42BE0F2F-BC45-437B-851D-E88A83201339}.Release|Any CPU.ActiveCfg = Release|Any CPU
{42BE0F2F-BC45-437B-851D-E88A83201339}.Release|Any CPU.Build.0 = Release|Any CPU
{B7148170-93C5-4F2F-B31D-85316D3248CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B7148170-93C5-4F2F-B31D-85316D3248CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B7148170-93C5-4F2F-B31D-85316D3248CF}.Proto|Any CPU.ActiveCfg = Debug|Any CPU
{B7148170-93C5-4F2F-B31D-85316D3248CF}.Proto|Any CPU.Build.0 = Debug|Any CPU
{B7148170-93C5-4F2F-B31D-85316D3248CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B7148170-93C5-4F2F-B31D-85316D3248CF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

namespace Conformance.PatternMatching

open Xunit
open FSharp.Test
open FSharp.Test.Compiler

module And =
// This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/And)
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"andPattern01.fs"|])>]
let ``And - andPattern01_fs - --test:ErrorRanges`` compilation =
compilation
|> asFs
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldSucceed

// This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/And)
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"andPattern02.fs"|])>]
let ``And - andPattern02_fs - --test:ErrorRanges`` compilation =
compilation
|> asFs
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldSucceed

// This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/And)
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"andPattern03.fs"|])>]
let ``And - andPattern03_fs - --test:ErrorRanges`` compilation =
compilation
|> asFs
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldSucceed

// This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/And)
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_IdentBoundTwice.fs"|])>]
let ``And - E_IdentBoundTwice_fs - --test:ErrorRanges`` compilation =
compilation
|> asFs
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldFail
|> withSingleDiagnostic (Error 38, Line 9, Col 20, Line 9, Col 21, "'x' is bound twice in this pattern")
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

open System

let (|ToInt|) x =
let (|ToInt|) (x: string) =
let (parsed, result) = Int32.TryParse(x)
if parsed then result
else -1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

namespace Conformance.PatternMatching

open Xunit
open FSharp.Test
open FSharp.Test.Compiler

module Array =
// This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Array)
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"arrayMatch01.fs"|])>]
let ``Array - arrayMatch01_fs - --test:ErrorRanges`` compilation =
compilation
|> asFs
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldSucceed

// This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Array)
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"arrayMatch02.fs"|])>]
let ``Array - arrayMatch02_fs - --test:ErrorRanges`` compilation =
compilation
|> asFs
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldSucceed

// This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Array)
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"arrayMatch03.fs"|])>]
let ``Array - arrayMatch03_fs - --test:ErrorRanges`` compilation =
compilation
|> asFs
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldSucceed

// This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Array)
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"TrailingSemi01.fs"|])>]
let ``Array - TrailingSemi01_fs - --test:ErrorRanges`` compilation =
compilation
|> asFs
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldSucceed
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

namespace Conformance.PatternMatching

open Xunit
open FSharp.Test
open FSharp.Test.Compiler

module As =
// This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/As)
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"asPattern01.fs"|])>]
let ``Simple - asPattern01_fs - --test:ErrorRanges`` compilation =
compilation
|> asFsx
|> withOptions ["--test:ErrorRanges"]
|> compile
|> shouldSucceed

// This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/As)
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"asPattern02.fs"|])>]
let ``Simple - asPattern02_fs - --test:ErrorRanges`` compilation =
compilation
|> asFsx
|> withOptions ["--test:ErrorRanges"]
|> compile
|> shouldSucceed

[<Fact>]
let ``As patterns``() =
Fsx """
let (|Id|) = id
let a = [1..4]
match a with
| 1 | 1 as b::(Id 2 as c as c2)::[d as 3; Id e & Id _ as Id 4] as Id f when b = 1 && c = 2 && c2 = 2 && d = 3 && e = 4 && a = f -> ()
| _ -> failwith "Match failed"
"""
|> asExe
|> withLangVersion60
|> compileExeAndRun
|> shouldSucceed

[<Theory>]
[<InlineData("DateTime", "DateTime.Now")>]
[<InlineData("int", "1")>]
[<InlineData("Guid", "(Guid.NewGuid())")>]
[<InlineData("Byte", "0x1")>]
[<InlineData("Decimal", "1m")>]
let ``Test type matching for subtypes and interfaces`` typ value =
Fsx $"""
open System
let classify (o: obj) =
match o with
| :? {typ} as d when d = Unchecked.defaultof<_> -> "default"
| :? IFormattable -> "formattable"
| _ -> "not a {typ}"

let res = classify {value}
if res <> "formattable" then
failwith $"Unexpected result: {{res}}"
"""
|> asExe
|> compileAndRun
|> shouldSucceed
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

namespace Conformance.PatternMatching

open Xunit
open FSharp.Test
open FSharp.Test.Compiler

module ConsList =
// This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/ConsList)
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"consPattern01.fs"|])>]
let ``ConsList - consPattern01_fs - --test:ErrorRanges`` compilation =
compilation
|> asFs
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldSucceed

// This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/ConsList)
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_consOnNonList.fs"|])>]
let ``ConsList - E_consOnNonList_fs - --test:ErrorRanges`` compilation =
compilation
|> asFs
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldFail
|> withDiagnostics [
(Error 1, Line 4, Col 21, Line 4, Col 28, "This expression was expected to have type
'int'
but here has type
''a list' ")
]

// This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/ConsList)
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_consPattern01.fs"|])>]
let ``ConsList - E_consPattern01_fs - --test:ErrorRanges`` compilation =
compilation
|> asFs
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldFail
|> withSingleDiagnostic (Error 1, Line 15, Col 22, Line 15, Col 24, "This expression was expected to have type
'int'
but here has type
''a list' ")

// This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/ConsList)
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"OutsideMatch01.fs"|])>]
let ``ConsList - OutsideMatch01_fs - --test:ErrorRanges`` compilation =
compilation
|> asFs
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldFail
|> withSingleDiagnostic (Warning 25, Line 6, Col 5, Line 6, Col 16, "Incomplete pattern matches on this expression. For example, the value '[_]' may indicate a case not covered by the pattern(s).")
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

namespace Conformance.PatternMatching

open Xunit
open FSharp.Test
open FSharp.Test.Compiler

module DynamicTypeTest =
// This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest)
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"ArrayTypeTest01.fs"|])>]
let ``DynamicTypeTest - consPattern01_fs - --test:ErrorRanges`` compilation =
compilation
|> asFs
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldSucceed

// This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest)
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"dynamicTypeTest01.fs"|])>]
let ``DynamicTypeTest - dynamicTypeTest01_fs - --test:ErrorRanges`` compilation =
compilation
|> asFs
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldSucceed

// This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest)
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"dynamicTypeTest02.fs"|])>]
let ``DynamicTypeTest - dynamicTypeTest02_fs - --test:ErrorRanges`` compilation =
compilation
|> asFs
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldFail
|> withDiagnostics [
(Warning 26, Line 31, Col 7, Line 31, Col 22, "This rule will never be matched")
(Warning 26, Line 32, Col 7, Line 32, Col 22, "This rule will never be matched")
]

// This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest)
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"dynamicTypeTest03.fs"|])>]
let ``DynamicTypeTest - dynamicTypeTest03_fs - --test:ErrorRanges`` compilation =
compilation
|> asFs
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldSucceed

// This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest)
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"dynamicTypeTest04.fs"|])>]
let ``DynamicTypeTest - dynamicTypeTest04_fs - --test:ErrorRanges`` compilation =
compilation
|> asFs
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldFail
|> withSingleDiagnostic (Warning 64, Line 8, Col 7, Line 8, Col 11, "This construct causes code to be less generic than indicated by its type annotations. The type variable implied by the use of a '#', '_' or other type annotation at or near 'dynamicTypeTest04.fs(8,9)-(8,10)' has been constrained to be type 'exn'.")

// This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest)
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"dynTestSealedType01.fs"|])>]
let ``DynamicTypeTest - dynTestSealedType01_fs - --test:ErrorRanges`` compilation =
compilation
|> asFs
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldSucceed

// This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest)
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_DynamicTestPrimType01.fs"|])>]
let ``DynamicTypeTest - E_DynamicTestPrimType01_fs - --test:ErrorRanges`` compilation =
compilation
|> asFs
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldFail
|> withSingleDiagnostic (Error 16, Line 11, Col 7, Line 11, Col 15, "The type 'int' does not have any proper subtypes and cannot be used as the source of a type test or runtime coercion.")

// This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest)
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_DynamTyTestVarType01.fs"|])>]
let ``DynamicTypeTest - E_DynamTyTestVarType01_fs - --test:ErrorRanges`` compilation =
compilation
|> asFs
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldFail
|> withSingleDiagnostic (Error 8, Line 12, Col 7, Line 12, Col 13, "This runtime coercion or type test from type
'a
to
obj
involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed.")

// This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest)
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"genericType01.fs"|])>]
let ``DynamicTypeTest - genericType01_fs - --test:ErrorRanges`` compilation =
compilation
|> asFs
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldSucceed

// This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest)
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Regression01.fs"|])>]
let ``DynamicTypeTest - Regression01_fs - --test:ErrorRanges`` compilation =
compilation
|> asFs
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldSucceed

// This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest)
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Regression02.fs"|])>]
let ``DynamicTypeTest - Regression02_fs - --test:ErrorRanges`` compilation =
compilation
|> asFs
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldSucceed

// This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest)
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"TwoAtOnce01.fs"|])>]
let ``DynamicTypeTest - TwoAtOnce01_fs - --test:ErrorRanges`` compilation =
compilation
|> asFs
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldSucceed

// This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest)
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"W_RedundantPattern01.fs"|])>]
let ``DynamicTypeTest - W_RedundantPattern01_fs - --test:ErrorRanges`` compilation =
compilation
|> asFs
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldFail
|> withDiagnostics [
(Warning 26, Line 12, Col 7, Line 12, Col 22, "This rule will never be matched")
(Warning 26, Line 18, Col 7, Line 18, Col 22, "This rule will never be matched")
]

// This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest)
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"W_TypeTestWillAlwaysHold01.fs"|])>]
let ``DynamicTypeTest - W_TypeTestWillAlwaysHold01_fs - --test:ErrorRanges`` compilation =
compilation
|> asFs
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldFail
|> withSingleDiagnostic (Warning 67, Line 13, Col 7, Line 13, Col 13, "This type test or downcast will always hold")
Loading