You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Disallow abstract member with access modifiers in sig file (#17802)
* Disallow abstract member with access modifiers in sig file
* release note
* format
* fix
* fix test
* use access modifier range to show error
* update tests
* update tests
* show both FS0531 and FS0561
---------
Co-authored-by: ijklam <43789618+Tangent-90@users.noreply.github.com>
Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com>
Copy file name to clipboardExpand all lines: docs/release-notes/.FSharp.Compiler.Service/9.0.200.md
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,8 @@
3
3
* Fix false negatives for passing null to "obj" arguments. Only "obj | null" can now subsume any type ([PR #17757](https://github.com/dotnet/fsharp/pull/17757))
4
4
* Fix internal error when calling 'AddSingleton' and other overloads only differing in generic arity ([PR #17804](https://github.com/dotnet/fsharp/pull/17804))
5
5
* Fix extension methods support for non-reference system assemblies ([PR #17799](https://github.com/dotnet/fsharp/pull/17799))
6
-
* Ensure `frameworkTcImportsCache` mutations are thread-safe. ([PR #17795](https://github.com/dotnet/fsharp/pull/17795))
6
+
* Ensure `frameworkTcImportsCache` mutations are threadsafe. ([PR #17795](https://github.com/dotnet/fsharp/pull/17795))
7
+
* Disallow abstract member with access modifiers in sig file. ([PR #17802](https://github.com/dotnet/fsharp/pull/17802))
7
8
* Fix concurrency issue in `ILPreTypeDefImpl` ([PR #17812](https://github.com/dotnet/fsharp/pull/17812))
8
9
* Fix nullness inference for member val and other OO scenarios ([PR #17845](https://github.com/dotnet/fsharp/pull/17845))
9
10
* Fix internal error when analyzing incomplete inherit member ([PR #17905](https://github.com/dotnet/fsharp/pull/17905))
Copy file name to clipboardExpand all lines: tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/AccessibilityAnnotations/PermittedLocations/PermittedLocations.fs
(Error 561, Line 18, Col 5, Line 18, Col 62,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
31
-
(Error 561, Line 19, Col 5, Line 19, Col 62,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
32
-
(Error 561, Line 20, Col 5, Line 20, Col 62,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
33
-
(Error 10, Line 21, Col 14, Line 21, Col 20,"Unexpected keyword 'public' in member definition. Expected identifier, '(', '(*)' or other token.")
34
-
(Error 561, Line 21, Col 14, Line 22, Col 62,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
35
-
(Error 10, Line 23, Col 14, Line 23, Col 22,"Unexpected keyword 'internal' in member definition. Expected identifier, '(', '(*)' or other token.")
30
+
(Error 531, Line 18, Col 5, Line 18, Col 11,"Accessibility modifiers should come immediately prior to the identifier naming a construct")
31
+
(Error 561, Line 18, Col 5, Line 18, Col 11,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
32
+
(Error 531, Line 19, Col 5, Line 19, Col 12,"Accessibility modifiers should come immediately prior to the identifier naming a construct")
33
+
(Error 561, Line 19, Col 5, Line 19, Col 12,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
34
+
(Error 531, Line 20, Col 5, Line 20, Col 13,"Accessibility modifiers should come immediately prior to the identifier naming a construct")
35
+
(Error 561, Line 20, Col 5, Line 20, Col 13,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
36
+
(Error 561, Line 21, Col 14, Line 21, Col 20,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
37
+
(Error 561, Line 22, Col 14, Line 22, Col 21,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
38
+
(Error 561, Line 23, Col 14, Line 23, Col 22,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
(Error 561, Line 13, Col 5, Line 13, Col 67,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
48
+
(Error 531, Line 13, Col 5, Line 13, Col 11,"Accessibility modifiers should come immediately prior to the identifier naming a construct")
49
+
(Error 561, Line 13, Col 5, Line 13, Col 11,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
(Error 561, Line 15, Col 5, Line 15, Col 68,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
59
+
(Error 531, Line 15, Col 5, Line 15, Col 12,"Accessibility modifiers should come immediately prior to the identifier naming a construct")
60
+
(Error 561, Line 15, Col 5, Line 15, Col 12,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
(Error 561, Line 15, Col 5, Line 15, Col 69,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
70
+
(Error 531, Line 15, Col 5, Line 15, Col 13,"Accessibility modifiers should come immediately prior to the identifier naming a construct")
71
+
(Error 561, Line 15, Col 5, Line 15, Col 13,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
(Error 10, Line 15, Col 14, Line 15, Col 20,"Unexpected keyword 'public' in member definition. Expected identifier, '(', '(*)' or other token.")
81
+
(Error 561, Line 15, Col 14, Line 15, Col 20,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
(Error 10, Line 15, Col 14, Line 15, Col 21,"Unexpected keyword 'private' in member definition. Expected identifier, '(', '(*)' or other token.")
91
+
(Error 561, Line 15, Col 14, Line 15, Col 21,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
(Error 10, Line 15, Col 14, Line 15, Col 22,"Unexpected keyword 'internal' in member definition. Expected identifier, '(', '(*)' or other token.")
101
+
(Error 561, Line 15, Col 14, Line 15, Col 22,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
(Error 531, Line 8, Col 13, Line 8, Col 20,"Accessibility modifiers should come immediately prior to the identifier naming a construct")
162
168
]
169
+
170
+
[<Fact>]
171
+
let``Signature File Test:abstract member cannot have access modifiers`` ()=
172
+
Fsi """module Program
173
+
174
+
type A =
175
+
abstract internal B: int ->int
176
+
abstract member internal E: int ->int
177
+
abstract member C: int with internal get, private set
178
+
abstract internal D: int with get, set
179
+
static abstract internal B2: int ->int
180
+
static abstract member internal E2: int ->int
181
+
static abstract member C2: int with internal get, private set
182
+
static abstract internal D2: int with get, set"""
183
+
|> withOptions ["--nowarn:3535"]
184
+
|> verifyCompile
185
+
|> shouldFail
186
+
|> withDiagnostics [
187
+
(Error 0561, Line 4, Col 14, Line 4, Col 22,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
188
+
(Error 0561, Line 5, Col 21, Line 5, Col 29,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
189
+
(Error 0561, Line 6, Col 33, Line 6, Col 41,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
190
+
(Error 0561, Line 6, Col 47, Line 6, Col 54,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
191
+
(Error 0561, Line 7, Col 14, Line 7, Col 22,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
192
+
(Error 0561, Line 8, Col 21, Line 8, Col 29,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
193
+
(Error 0561, Line 9, Col 28, Line 9, Col 36,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
194
+
(Error 0561, Line 10, Col 41, Line 10, Col 49,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
195
+
(Error 0561, Line 10, Col 55, Line 10, Col 62,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
196
+
(Error 0561, Line 11, Col 21, Line 11, Col 29,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
Copy file name to clipboardExpand all lines: tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/MemberDefinitions/MethodsAndProperties/AutoPropsWithModifierBeforeGetSet.fs
+7-6Lines changed: 7 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -110,11 +110,12 @@ let ``Abstract Properties Test: access modifiers are not allowed`` () =
110
110
|> typecheck
111
111
|> shouldFail
112
112
|> withDiagnostics [
113
-
(Error 0561, Line 6, Col 5, Line 6, Col 51,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
114
-
(Error 0561, Line 8, Col 5, Line 8, Col 51,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
115
-
(Error 0561, Line 10, Col 5, Line 10, Col 60,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
116
-
(Error 0561, Line 12, Col 5, Line 12, Col 46,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
117
-
(Error 0561, Line 14, Col 5, Line 14, Col 46,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
113
+
(Error 0561, Line 6, Col 34, Line 6, Col 42,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
114
+
(Error 0561, Line 8, Col 39, Line 8, Col 47,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
115
+
(Error 0561, Line 10, Col 34, Line 10, Col 42,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
116
+
(Error 0561, Line 10, Col 48, Line 10, Col 56,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
117
+
(Error 0561, Line 12, Col 34, Line 12, Col 42,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
118
+
(Error 0561, Line 14, Col 34, Line 14, Col 42,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
118
119
]
119
120
120
121
[<Fact>]
@@ -132,7 +133,7 @@ type A =
132
133
|> verifyCompile
133
134
|> shouldFail
134
135
|> withDiagnostics [
135
-
(Error 240, Line 1, Col 1, Line 9, Col 42,"The signature file 'Program' does not have a corresponding implementation file. If an implementation file exists then check the 'module' and 'namespace' declarations in the signature and implementation files match.")
136
+
(Error 0561, Line 9, Col 31, Line 9, Col 38,"Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.")
0 commit comments