Skip to content

Commit 43a4c21

Browse files
authored
Merge branch 'main' into allow-and-bang-typed-bindings
2 parents 4712569 + 6596de5 commit 43a4c21

File tree

9 files changed

+605
-20
lines changed

9 files changed

+605
-20
lines changed

.github/workflows/copilot-setup-steps.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ jobs:
2121
- name: Restore the compiler service solution
2222
env:
2323
CI: false
24-
run: dotnet build ./FSharp.Compiler.Service.sln --verbosity quiet
24+
run: ./build.sh -c Release --verbosity quiet
2525
- name: Restore the language server solution
2626
env:
2727
CI: false
28-
run: dotnet build ./VSFSharpExtension.sln --verbosity quiet
28+
run: dotnet build ./LSPSolutionSlim.sln -c Release --verbosity quiet
2929
- name: Restore dotnet tools
3030
env:
3131
CI: false

LSPSolutionSlim.sln

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31903.59
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{827E0CD3-B72D-47B6-A68D-7590B98EB39B}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Compiler", "Compiler", "{87D01E8D-2580-81A2-8FDB-46C6008C302D}"
9+
EndProject
10+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler.Service", "src\Compiler\FSharp.Compiler.Service.fsproj", "{876C64E7-1131-48AD-BD7B-CB3E17CB0E93}"
11+
EndProject
12+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.DependencyManager.Nuget", "src\FSharp.DependencyManager.Nuget\FSharp.DependencyManager.Nuget.fsproj", "{BD632E2B-6A64-458A-B236-37D5B35F3ACD}"
13+
EndProject
14+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Core", "src\FSharp.Core\FSharp.Core.fsproj", "{350BB272-96EF-462C-BDF7-1E711FB1C684}"
15+
EndProject
16+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FSharp.VisualStudio.Extension", "src\FSharp.VisualStudio.Extension\FSharp.VisualStudio.Extension.csproj", "{F78BF321-03DE-41B0-BBDA-700A49DDD541}"
17+
EndProject
18+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler.LanguageServer", "src\FSharp.Compiler.LanguageServer\FSharp.Compiler.LanguageServer.fsproj", "{72C85CB8-674E-40B8-A972-1710E503DDCD}"
19+
EndProject
20+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.CommonLanguageServerProtocol.Framework.Proxy", "src\Microsoft.CommonLanguageServerProtocol.Framework.Proxy\Microsoft.CommonLanguageServerProtocol.Framework.Proxy.csproj", "{71F0B4AC-786A-498E-88C7-2B922025F192}"
21+
EndProject
22+
Global
23+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
24+
Debug|Any CPU = Debug|Any CPU
25+
Debug|x64 = Debug|x64
26+
Debug|x86 = Debug|x86
27+
Release|Any CPU = Release|Any CPU
28+
Release|x64 = Release|x64
29+
Release|x86 = Release|x86
30+
EndGlobalSection
31+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
32+
{876C64E7-1131-48AD-BD7B-CB3E17CB0E93}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33+
{876C64E7-1131-48AD-BD7B-CB3E17CB0E93}.Debug|Any CPU.Build.0 = Debug|Any CPU
34+
{876C64E7-1131-48AD-BD7B-CB3E17CB0E93}.Debug|x64.ActiveCfg = Debug|Any CPU
35+
{876C64E7-1131-48AD-BD7B-CB3E17CB0E93}.Debug|x64.Build.0 = Debug|Any CPU
36+
{876C64E7-1131-48AD-BD7B-CB3E17CB0E93}.Debug|x86.ActiveCfg = Debug|Any CPU
37+
{876C64E7-1131-48AD-BD7B-CB3E17CB0E93}.Debug|x86.Build.0 = Debug|Any CPU
38+
{876C64E7-1131-48AD-BD7B-CB3E17CB0E93}.Release|Any CPU.ActiveCfg = Release|Any CPU
39+
{876C64E7-1131-48AD-BD7B-CB3E17CB0E93}.Release|Any CPU.Build.0 = Release|Any CPU
40+
{876C64E7-1131-48AD-BD7B-CB3E17CB0E93}.Release|x64.ActiveCfg = Release|Any CPU
41+
{876C64E7-1131-48AD-BD7B-CB3E17CB0E93}.Release|x64.Build.0 = Release|Any CPU
42+
{876C64E7-1131-48AD-BD7B-CB3E17CB0E93}.Release|x86.ActiveCfg = Release|Any CPU
43+
{876C64E7-1131-48AD-BD7B-CB3E17CB0E93}.Release|x86.Build.0 = Release|Any CPU
44+
{BD632E2B-6A64-458A-B236-37D5B35F3ACD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
45+
{BD632E2B-6A64-458A-B236-37D5B35F3ACD}.Debug|Any CPU.Build.0 = Debug|Any CPU
46+
{BD632E2B-6A64-458A-B236-37D5B35F3ACD}.Debug|x64.ActiveCfg = Debug|Any CPU
47+
{BD632E2B-6A64-458A-B236-37D5B35F3ACD}.Debug|x64.Build.0 = Debug|Any CPU
48+
{BD632E2B-6A64-458A-B236-37D5B35F3ACD}.Debug|x86.ActiveCfg = Debug|Any CPU
49+
{BD632E2B-6A64-458A-B236-37D5B35F3ACD}.Debug|x86.Build.0 = Debug|Any CPU
50+
{BD632E2B-6A64-458A-B236-37D5B35F3ACD}.Release|Any CPU.ActiveCfg = Release|Any CPU
51+
{BD632E2B-6A64-458A-B236-37D5B35F3ACD}.Release|Any CPU.Build.0 = Release|Any CPU
52+
{BD632E2B-6A64-458A-B236-37D5B35F3ACD}.Release|x64.ActiveCfg = Release|Any CPU
53+
{BD632E2B-6A64-458A-B236-37D5B35F3ACD}.Release|x64.Build.0 = Release|Any CPU
54+
{BD632E2B-6A64-458A-B236-37D5B35F3ACD}.Release|x86.ActiveCfg = Release|Any CPU
55+
{BD632E2B-6A64-458A-B236-37D5B35F3ACD}.Release|x86.Build.0 = Release|Any CPU
56+
{350BB272-96EF-462C-BDF7-1E711FB1C684}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
57+
{350BB272-96EF-462C-BDF7-1E711FB1C684}.Debug|Any CPU.Build.0 = Debug|Any CPU
58+
{350BB272-96EF-462C-BDF7-1E711FB1C684}.Debug|x64.ActiveCfg = Debug|Any CPU
59+
{350BB272-96EF-462C-BDF7-1E711FB1C684}.Debug|x64.Build.0 = Debug|Any CPU
60+
{350BB272-96EF-462C-BDF7-1E711FB1C684}.Debug|x86.ActiveCfg = Debug|Any CPU
61+
{350BB272-96EF-462C-BDF7-1E711FB1C684}.Debug|x86.Build.0 = Debug|Any CPU
62+
{350BB272-96EF-462C-BDF7-1E711FB1C684}.Release|Any CPU.ActiveCfg = Release|Any CPU
63+
{350BB272-96EF-462C-BDF7-1E711FB1C684}.Release|Any CPU.Build.0 = Release|Any CPU
64+
{350BB272-96EF-462C-BDF7-1E711FB1C684}.Release|x64.ActiveCfg = Release|Any CPU
65+
{350BB272-96EF-462C-BDF7-1E711FB1C684}.Release|x64.Build.0 = Release|Any CPU
66+
{350BB272-96EF-462C-BDF7-1E711FB1C684}.Release|x86.ActiveCfg = Release|Any CPU
67+
{350BB272-96EF-462C-BDF7-1E711FB1C684}.Release|x86.Build.0 = Release|Any CPU
68+
{F78BF321-03DE-41B0-BBDA-700A49DDD541}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
69+
{F78BF321-03DE-41B0-BBDA-700A49DDD541}.Debug|Any CPU.Build.0 = Debug|Any CPU
70+
{F78BF321-03DE-41B0-BBDA-700A49DDD541}.Debug|x64.ActiveCfg = Debug|Any CPU
71+
{F78BF321-03DE-41B0-BBDA-700A49DDD541}.Debug|x64.Build.0 = Debug|Any CPU
72+
{F78BF321-03DE-41B0-BBDA-700A49DDD541}.Debug|x86.ActiveCfg = Debug|Any CPU
73+
{F78BF321-03DE-41B0-BBDA-700A49DDD541}.Debug|x86.Build.0 = Debug|Any CPU
74+
{F78BF321-03DE-41B0-BBDA-700A49DDD541}.Release|Any CPU.ActiveCfg = Release|Any CPU
75+
{F78BF321-03DE-41B0-BBDA-700A49DDD541}.Release|Any CPU.Build.0 = Release|Any CPU
76+
{F78BF321-03DE-41B0-BBDA-700A49DDD541}.Release|x64.ActiveCfg = Release|Any CPU
77+
{F78BF321-03DE-41B0-BBDA-700A49DDD541}.Release|x64.Build.0 = Release|Any CPU
78+
{F78BF321-03DE-41B0-BBDA-700A49DDD541}.Release|x86.ActiveCfg = Release|Any CPU
79+
{F78BF321-03DE-41B0-BBDA-700A49DDD541}.Release|x86.Build.0 = Release|Any CPU
80+
{72C85CB8-674E-40B8-A972-1710E503DDCD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
81+
{72C85CB8-674E-40B8-A972-1710E503DDCD}.Debug|Any CPU.Build.0 = Debug|Any CPU
82+
{72C85CB8-674E-40B8-A972-1710E503DDCD}.Debug|x64.ActiveCfg = Debug|Any CPU
83+
{72C85CB8-674E-40B8-A972-1710E503DDCD}.Debug|x64.Build.0 = Debug|Any CPU
84+
{72C85CB8-674E-40B8-A972-1710E503DDCD}.Debug|x86.ActiveCfg = Debug|Any CPU
85+
{72C85CB8-674E-40B8-A972-1710E503DDCD}.Debug|x86.Build.0 = Debug|Any CPU
86+
{72C85CB8-674E-40B8-A972-1710E503DDCD}.Release|Any CPU.ActiveCfg = Release|Any CPU
87+
{72C85CB8-674E-40B8-A972-1710E503DDCD}.Release|Any CPU.Build.0 = Release|Any CPU
88+
{72C85CB8-674E-40B8-A972-1710E503DDCD}.Release|x64.ActiveCfg = Release|Any CPU
89+
{72C85CB8-674E-40B8-A972-1710E503DDCD}.Release|x64.Build.0 = Release|Any CPU
90+
{72C85CB8-674E-40B8-A972-1710E503DDCD}.Release|x86.ActiveCfg = Release|Any CPU
91+
{72C85CB8-674E-40B8-A972-1710E503DDCD}.Release|x86.Build.0 = Release|Any CPU
92+
{71F0B4AC-786A-498E-88C7-2B922025F192}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
93+
{71F0B4AC-786A-498E-88C7-2B922025F192}.Debug|Any CPU.Build.0 = Debug|Any CPU
94+
{71F0B4AC-786A-498E-88C7-2B922025F192}.Debug|x64.ActiveCfg = Debug|Any CPU
95+
{71F0B4AC-786A-498E-88C7-2B922025F192}.Debug|x64.Build.0 = Debug|Any CPU
96+
{71F0B4AC-786A-498E-88C7-2B922025F192}.Debug|x86.ActiveCfg = Debug|Any CPU
97+
{71F0B4AC-786A-498E-88C7-2B922025F192}.Debug|x86.Build.0 = Debug|Any CPU
98+
{71F0B4AC-786A-498E-88C7-2B922025F192}.Release|Any CPU.ActiveCfg = Release|Any CPU
99+
{71F0B4AC-786A-498E-88C7-2B922025F192}.Release|Any CPU.Build.0 = Release|Any CPU
100+
{71F0B4AC-786A-498E-88C7-2B922025F192}.Release|x64.ActiveCfg = Release|Any CPU
101+
{71F0B4AC-786A-498E-88C7-2B922025F192}.Release|x64.Build.0 = Release|Any CPU
102+
{71F0B4AC-786A-498E-88C7-2B922025F192}.Release|x86.ActiveCfg = Release|Any CPU
103+
{71F0B4AC-786A-498E-88C7-2B922025F192}.Release|x86.Build.0 = Release|Any CPU
104+
EndGlobalSection
105+
GlobalSection(SolutionProperties) = preSolution
106+
HideSolutionNode = FALSE
107+
EndGlobalSection
108+
GlobalSection(NestedProjects) = preSolution
109+
{87D01E8D-2580-81A2-8FDB-46C6008C302D} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
110+
{876C64E7-1131-48AD-BD7B-CB3E17CB0E93} = {87D01E8D-2580-81A2-8FDB-46C6008C302D}
111+
{BD632E2B-6A64-458A-B236-37D5B35F3ACD} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
112+
{350BB272-96EF-462C-BDF7-1E711FB1C684} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
113+
{F78BF321-03DE-41B0-BBDA-700A49DDD541} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
114+
{72C85CB8-674E-40B8-A972-1710E503DDCD} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
115+
{71F0B4AC-786A-498E-88C7-2B922025F192} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
116+
EndGlobalSection
117+
EndGlobal

eng/Version.Details.xml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,25 @@
3939
<Uri>https://github.com/dotnet/arcade</Uri>
4040
<Sha>12d3a9f5d6138e22270694574e73e4c58a815795</Sha>
4141
</Dependency>
42-
<Dependency Name="optimization.windows_nt-x64.MIBC.Runtime" Version="1.0.0-prerelease.25309.1">
42+
<Dependency Name="optimization.windows_nt-x64.MIBC.Runtime" Version="1.0.0-prerelease.25317.1">
4343
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-optimization</Uri>
44-
<Sha>b1f3f5c40f86362217f1b98952d5c6562d609619</Sha>
44+
<Sha>c6572c564a548af3094483ce1aab7bf01f0478f9</Sha>
4545
</Dependency>
46-
<Dependency Name="optimization.windows_nt-x86.MIBC.Runtime" Version="1.0.0-prerelease.25309.1">
46+
<Dependency Name="optimization.windows_nt-x86.MIBC.Runtime" Version="1.0.0-prerelease.25317.1">
4747
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-optimization</Uri>
48-
<Sha>b1f3f5c40f86362217f1b98952d5c6562d609619</Sha>
48+
<Sha>c6572c564a548af3094483ce1aab7bf01f0478f9</Sha>
4949
</Dependency>
50-
<Dependency Name="optimization.linux-x64.MIBC.Runtime" Version="1.0.0-prerelease.25309.1">
50+
<Dependency Name="optimization.linux-x64.MIBC.Runtime" Version="1.0.0-prerelease.25317.1">
5151
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-optimization</Uri>
52-
<Sha>b1f3f5c40f86362217f1b98952d5c6562d609619</Sha>
52+
<Sha>c6572c564a548af3094483ce1aab7bf01f0478f9</Sha>
5353
</Dependency>
54-
<Dependency Name="optimization.windows_nt-arm64.MIBC.Runtime" Version="1.0.0-prerelease.25309.1">
54+
<Dependency Name="optimization.windows_nt-arm64.MIBC.Runtime" Version="1.0.0-prerelease.25317.1">
5555
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-optimization</Uri>
56-
<Sha>b1f3f5c40f86362217f1b98952d5c6562d609619</Sha>
56+
<Sha>c6572c564a548af3094483ce1aab7bf01f0478f9</Sha>
5757
</Dependency>
58-
<Dependency Name="optimization.linux-arm64.MIBC.Runtime" Version="1.0.0-prerelease.25309.1">
58+
<Dependency Name="optimization.linux-arm64.MIBC.Runtime" Version="1.0.0-prerelease.25317.1">
5959
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-optimization</Uri>
60-
<Sha>b1f3f5c40f86362217f1b98952d5c6562d609619</Sha>
60+
<Sha>c6572c564a548af3094483ce1aab7bf01f0478f9</Sha>
6161
</Dependency>
6262
</ToolsetDependencies>
6363
</Dependencies>

eng/Versions.props

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,10 @@
205205
<HumanizerCoreVersion>2.2.0</HumanizerCoreVersion>
206206
<!-- -->
207207
<!-- MIBC profile packages -->
208-
<optimizationwindows_ntx64MIBCRuntimeVersion>1.0.0-prerelease.25309.1</optimizationwindows_ntx64MIBCRuntimeVersion>
209-
<optimizationwindows_ntx86MIBCRuntimeVersion>1.0.0-prerelease.25309.1</optimizationwindows_ntx86MIBCRuntimeVersion>
210-
<optimizationwindows_ntarm64MIBCRuntimeVersion>1.0.0-prerelease.25309.1</optimizationwindows_ntarm64MIBCRuntimeVersion>
211-
<optimizationlinuxx64MIBCRuntimeVersion>1.0.0-prerelease.25309.1</optimizationlinuxx64MIBCRuntimeVersion>
212-
<optimizationlinuxarm64MIBCRuntimeVersion>1.0.0-prerelease.25309.1</optimizationlinuxarm64MIBCRuntimeVersion>
208+
<optimizationwindows_ntx64MIBCRuntimeVersion>1.0.0-prerelease.25317.1</optimizationwindows_ntx64MIBCRuntimeVersion>
209+
<optimizationwindows_ntx86MIBCRuntimeVersion>1.0.0-prerelease.25317.1</optimizationwindows_ntx86MIBCRuntimeVersion>
210+
<optimizationwindows_ntarm64MIBCRuntimeVersion>1.0.0-prerelease.25317.1</optimizationwindows_ntarm64MIBCRuntimeVersion>
211+
<optimizationlinuxx64MIBCRuntimeVersion>1.0.0-prerelease.25317.1</optimizationlinuxx64MIBCRuntimeVersion>
212+
<optimizationlinuxarm64MIBCRuntimeVersion>1.0.0-prerelease.25317.1</optimizationlinuxarm64MIBCRuntimeVersion>
213213
</PropertyGroup>
214214
</Project>

src/FSharp.VisualStudio.Extension/FSharp.VisualStudio.Extension.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net8.0-windows</TargetFramework>
3+
<TargetFramework Condition="$([MSBuild]::IsOSPlatform('Windows'))">net8.0-windows</TargetFramework>
4+
<!-- Main reason for this is to be able to build on ubuntu - for testing purposes -->
5+
<!-- Not sure if VS Extensibility actually works on non-Windows platforms, but we mostly care about building it here -->
6+
<TargetFramework Condition="!$([MSBuild]::IsOSPlatform('Windows'))">net8.0</TargetFramework>
47
<Nullable>enable</Nullable>
58
<LangVersion>12</LangVersion>
69
<NeutralLanguage>en-US</NeutralLanguage>
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
2+
3+
module ErrorMessages.AbbreviationTests
4+
5+
open Xunit
6+
open FSharp.Test.Compiler
7+
8+
[<Fact>]
9+
let ``Members 01`` () =
10+
Fsx """
11+
type StringAlias = string
12+
13+
type StringAlias with
14+
member x.Length = x.Length
15+
"""
16+
|> typecheck
17+
|> shouldFail
18+
|> withDiagnostics [
19+
(Error 964, Line 4, Col 6, Line 4, Col 17, "Type abbreviations cannot have augmentations")
20+
(Error 895, Line 5, Col 5, Line 5, Col 31, "Type abbreviations cannot have members")
21+
]
22+
23+
[<Fact>]
24+
let ``Members 02 - Interface impl`` () =
25+
Fsx """
26+
type IntAlias = int
27+
28+
type IntAlias with
29+
interface System.IComparable with
30+
member x.CompareTo(obj) = 0
31+
"""
32+
|> typecheck
33+
|> shouldFail
34+
|> withDiagnostics [
35+
(Error 964, Line 4, Col 6, Line 4, Col 14, "Type abbreviations cannot have augmentations")
36+
(Error 906, Line 5, Col 15, Line 5, Col 33, "Type abbreviations cannot have interface declarations")
37+
(Error 909, Line 5, Col 15, Line 5, Col 33, "All implemented interfaces should be declared on the initial declaration of the type")
38+
]
39+
40+
[<Fact>]
41+
let ``Members 03 - Members and interface`` () =
42+
Fsx """
43+
type FloatAlias = float
44+
45+
type FloatAlias with
46+
member x.IsNaN = System.Double.IsNaN(x)
47+
interface System.IConvertible
48+
"""
49+
|> typecheck
50+
|> shouldFail
51+
|> withDiagnostics [
52+
(Error 964, Line 4, Col 6, Line 4, Col 16, "Type abbreviations cannot have augmentations")
53+
(Error 906, Line 6, Col 15, Line 6, Col 34, "Type abbreviations cannot have interface declarations")
54+
(Error 909, Line 6, Col 15, Line 6, Col 34, "All implemented interfaces should be declared on the initial declaration of the type")
55+
]
56+
57+
[<Fact>]
58+
let ``Multiple types 01`` () =
59+
Fsx """
60+
type ListAlias = int list
61+
type ArrayAlias = string[]
62+
63+
type ListAlias with
64+
member x.Head = x.Head
65+
66+
type ArrayAlias with
67+
member x.Length = x.Length
68+
"""
69+
|> typecheck
70+
|> shouldFail
71+
|> withDiagnostics [
72+
(Error 964, Line 5, Col 6, Line 5, Col 15, "Type abbreviations cannot have augmentations")
73+
(Error 895, Line 6, Col 5, Line 6, Col 27, "Type abbreviations cannot have members")
74+
(Error 964, Line 8, Col 6, Line 8, Col 16, "Type abbreviations cannot have augmentations")
75+
(Error 895, Line 9, Col 5, Line 9, Col 31, "Type abbreviations cannot have members")
76+
]
77+
78+
[<Fact>]
79+
let ``Multiple types 02 - With interface`` () =
80+
Fsx """
81+
type ArrayAlias = string[]
82+
83+
type ArrayAlias with
84+
interface System.Collections.IEnumerable with
85+
member x.GetEnumerator() = null
86+
"""
87+
|> typecheck
88+
|> shouldFail
89+
|> withDiagnostics [
90+
(Error 964, Line 4, Col 6, Line 4, Col 16, "Type abbreviations cannot have augmentations")
91+
(Error 906, Line 5, Col 15, Line 5, Col 45, "Type abbreviations cannot have interface declarations")
92+
(Error 909, Line 5, Col 15, Line 5, Col 45, "All implemented interfaces should be declared on the initial declaration of the type")
93+
]
94+
[<Fact>]
95+
let ``Nested 01`` () =
96+
Fsx """
97+
namespace Test
98+
99+
type Alias1 = int
100+
101+
module Nested =
102+
type Alias2 = string
103+
104+
type Alias1 with
105+
member x.Value = x
106+
"""
107+
|> typecheck
108+
|> shouldFail
109+
|> withDiagnostics [
110+
(Error 964, Line 9, Col 10, Line 9, Col 16, "Type abbreviations cannot have augmentations");
111+
(Error 895, Line 10, Col 9, Line 10, Col 27, "Type abbreviations cannot have members");
112+
]
113+
114+
[<Fact>]
115+
let ``Nested 02 - Different namespace`` () =
116+
Fsx """
117+
namespace Test
118+
119+
module Nested =
120+
type Alias2 = string
121+
122+
type Alias2 with
123+
interface System.IComparable with
124+
member x.CompareTo(obj) = 0
125+
126+
open Nested
127+
128+
type Alias2 with
129+
member x.ToUpper() = x.ToUpper()
130+
"""
131+
|> typecheck
132+
|> shouldFail
133+
|> withDiagnostics [
134+
(Error 964, Line 7, Col 10, Line 7, Col 16, "Type abbreviations cannot have augmentations");
135+
(Error 906, Line 8, Col 19, Line 8, Col 37, "Type abbreviations cannot have interface declarations");
136+
(Error 909, Line 8, Col 19, Line 8, Col 37, "All implemented interfaces should be declared on the initial declaration of the type");
137+
(Error 964, Line 13, Col 6, Line 13, Col 12, "Type abbreviations cannot have augmentations");
138+
(Error 895, Line 14, Col 5, Line 14, Col 37, "Type abbreviations cannot have members");
139+
(Error 644, Line 14, Col 14, Line 14, Col 21, "Namespaces cannot contain extension members except in the same file and namespace declaration group where the type is defined. Consider using a module to hold declarations of extension members.");
140+
]
141+
142+
[<Fact>]
143+
let ``Generic 01`` () =
144+
Fsx """
145+
type Result<'T> = Result<'T, string>
146+
147+
type Result<'T> with
148+
member x.IsOk = match x with Ok _ -> true | Error _ -> false
149+
"""
150+
|> typecheck
151+
|> shouldFail
152+
|> withDiagnostics [
153+
(Error 964, Line 4, Col 6, Line 4, Col 12, "Type abbreviations cannot have augmentations");
154+
(Error 895, Line 5, Col 5, Line 5, Col 65, "Type abbreviations cannot have members");
155+
]
156+
157+
[<Fact>]
158+
let ``Generic 02 - Interface`` () =
159+
Fsx """
160+
type MyList<'a> = 'a list
161+
162+
type MyList<'a> with
163+
interface seq<'a> with
164+
member x.GetEnumerator() = (x :> seq<'a>).GetEnumerator()
165+
"""
166+
|> typecheck
167+
|> shouldFail
168+
|> withDiagnostics [
169+
(Error 964, Line 4, Col 6, Line 4, Col 12, "Type abbreviations cannot have augmentations");
170+
(Error 906, Line 5, Col 15, Line 5, Col 22, "Type abbreviations cannot have interface declarations");
171+
(Error 909, Line 5, Col 15, Line 5, Col 22, "All implemented interfaces should be declared on the initial declaration of the type")
172+
]
173+
174+
[<Fact>]
175+
let ``Property getters and setters`` () =
176+
Fsx """
177+
type IntRef = int ref
178+
179+
type IntRef with
180+
member x.Value
181+
with get() = !x
182+
and set(v) = x := v
183+
"""
184+
|> typecheck
185+
|> shouldFail
186+
|> withDiagnostics [
187+
(Error 964, Line 4, Col 6, Line 4, Col 12, "Type abbreviations cannot have augmentations")
188+
(Error 895, Line 5, Col 5, Line 6, Col 1, "Type abbreviations cannot have members")
189+
]

0 commit comments

Comments
 (0)