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
{{ message }}
This repository was archived by the owner on Dec 23, 2024. It is now read-only.
letwarning44Message="This construct is deprecated. The type 'Hidden' is less accessible than the value, member or type 'Exported' it is used in."+ System.Environment.NewLine +"As of F# 4.1, the accessibility of type abbreviations is checked at compile-time. Consider changing the accessibility of the type abbreviation. Ignoring this warning might lead to runtime errors."
12
+
11
13
[<Fact>]
12
14
let``Private type produces warning when trying to export``()=
13
-
CompilerAssert.TypeCheckSingleError
14
-
"""
15
+
FSharp """
15
16
module Library =
16
17
type private Hidden = Hidden of unit
17
18
type Exported = Hidden
18
-
"""
19
-
FSharpErrorSeverity.Warning
20
-
44
21
-
(4,8,4,16)
22
-
("This construct is deprecated. The type 'Hidden' is less accessible than the value, member or type 'Exported' it is used in."+ System.Environment.NewLine +"As of F# 4.1, the accessibility of type abbreviations is checked at compile-time. Consider changing the accessibility of the type abbreviation. Ignoring this warning might lead to runtime errors.")
19
+
"""
20
+
|> typecheck
21
+
|> shouldFail
22
+
|> withSingleDiagnostic (Warning 44, Line 4, Col 8, Line 4, Col 16, warning44Message)
23
23
24
24
[<Fact>]
25
25
let``Internal type passes when abbrev is internal``()=
26
-
CompilerAssert.Pass
27
-
"""
26
+
FSharp """
28
27
module Library =
29
28
type internal Hidden = Hidden of unit
30
29
type internal Exported = Hidden
31
-
"""
30
+
"""
31
+
|> typecheck
32
+
|> shouldSucceed
32
33
33
34
[<Fact>]
34
35
let``Internal type produces warning when trying to export``()=
35
-
CompilerAssert.TypeCheckSingleError
36
-
"""
36
+
FSharp """
37
37
module Library =
38
38
type internal Hidden = Hidden of unit
39
39
type Exported = Hidden
40
-
"""
41
-
FSharpErrorSeverity.Warning
42
-
44
43
-
(4,8,4,16)
44
-
("This construct is deprecated. The type 'Hidden' is less accessible than the value, member or type 'Exported' it is used in."+ System.Environment.NewLine +"As of F# 4.1, the accessibility of type abbreviations is checked at compile-time. Consider changing the accessibility of the type abbreviation. Ignoring this warning might lead to runtime errors.")
40
+
"""
41
+
|> typecheck
42
+
|> shouldFail
43
+
|> withSingleDiagnostic (Warning 44, Line 4, Col 8, Line 4, Col 16, warning44Message)
45
44
46
45
[<Fact>]
47
46
let``Private type produces warning when abbrev is internal``()=
48
-
CompilerAssert.TypeCheckSingleError
49
-
"""
47
+
FSharp """
50
48
module Library =
51
49
type private Hidden = Hidden of unit
52
50
type internal Exported = Hidden
53
-
"""
54
-
FSharpErrorSeverity.Warning
55
-
44
56
-
(4,17,4,25)
57
-
("This construct is deprecated. The type 'Hidden' is less accessible than the value, member or type 'Exported' it is used in."+ System.Environment.NewLine +"As of F# 4.1, the accessibility of type abbreviations is checked at compile-time. Consider changing the accessibility of the type abbreviation. Ignoring this warning might lead to runtime errors.")
51
+
"""
52
+
|> typecheck
53
+
|> shouldFail
54
+
|> withSingleDiagnostic (Warning 44, Line 4, Col 17, Line 4, Col 25, warning44Message)
58
55
59
56
[<Fact>]
60
57
let``Private type passes when abbrev is private``()=
61
-
CompilerAssert.Pass
62
-
"""
58
+
FSharp """
63
59
module Library =
64
60
type private Hidden = Hidden of unit
65
61
type private Exported = Hidden
66
-
"""
62
+
"""
63
+
|> typecheck
64
+
|> shouldSucceed
67
65
68
66
[<Fact>]
69
67
let``Default access type passes when abbrev is default``()=
FSharpErrorSeverity.Error,768,(7,16,7,36),"The member 'Function' does not accept the correct number of arguments. 1 argument(s) are expected, but 2 were given. The required signature is 'member IInterface.Function : (int32 * int32) -> unit'.\nA tuple type is required for one or more arguments. Consider wrapping the given arguments in additional parentheses or review the definition of the interface."
25
-
FSharpErrorSeverity.Error,17,(7,21,7,29),"The member 'Function : 'a * 'b -> unit' does not have the correct type to override the corresponding abstract method. The required signature is 'Function : (int32 * int32) -> unit'."
26
-
FSharpErrorSeverity.Error,783,(6,9,6,19),"At least one override did not correctly implement its corresponding abstract member"
27
-
|]
20
+
"""
21
+
|> typecheck
22
+
|> shouldFail
23
+
|> withDiagnostics [
24
+
(Error 768, Line 7, Col 16, Line 7, Col 36,"The member 'Function' does not accept the correct number of arguments. 1 argument(s) are expected, but 2 were given. The required signature is 'member IInterface.Function : (int32 * int32) -> unit'.\nA tuple type is required for one or more arguments. Consider wrapping the given arguments in additional parentheses or review the definition of the interface.")
25
+
(Error 17, Line 7, Col 21, Line 7, Col 29,"The member 'Function : 'a * 'b -> unit' does not have the correct type to override the corresponding abstract method. The required signature is 'Function : (int32 * int32) -> unit'.")
26
+
(Error 783, Line 6, Col 9, Line 6, Col 19,"At least one override did not correctly implement its corresponding abstract member")]
28
27
29
28
[<Fact>]
30
29
let``Wrong Arity``()=
31
-
CompilerAssert.TypeCheckSingleError
32
-
"""
30
+
FSharp """
33
31
type MyType() =
34
32
static member MyMember(arg1, arg2:int ) = ()
35
33
static member MyMember(arg1, arg2:byte) = ()
36
34
37
35
38
36
MyType.MyMember("", 0, 0)
39
-
"""
40
-
FSharpErrorSeverity.Error
41
-
503
42
-
(7,1,7,26)
43
-
"A member or object constructor 'MyMember' taking 3 arguments is not accessible from this code location. All accessible versions of method 'MyMember' take 2 arguments."
37
+
"""
38
+
|> typecheck
39
+
|> shouldFail
40
+
|> withSingleDiagnostic (Error 503, Line 7,Col 1,Line 7,Col 26,
41
+
"A member or object constructor 'MyMember' taking 3 arguments is not accessible from this code location. All accessible versions of method 'MyMember' take 2 arguments.")
44
42
45
43
[<Fact>]
46
44
let``Method Is Not Static``()=
47
-
CompilerAssert.TypeCheckSingleError
48
-
"""
45
+
FSharp """
49
46
type Class1() =
50
47
member this.X() = "F#"
51
48
52
49
let x = Class1.X()
53
-
"""
54
-
FSharpErrorSeverity.Error
55
-
3214
56
-
(5,9,5,17)
57
-
"Method or object constructor 'X' is not static"
50
+
"""
51
+
|> typecheck
52
+
|> shouldFail
53
+
|> withSingleDiagnostic (Error 3214, Line 5, Col 9, Line 5, Col 17,"Method or object constructor 'X' is not static")
58
54
59
55
[<Fact>]
60
56
let``Matching Method With Same Name Is Not Abstract``()=
61
-
CompilerAssert.TypeCheckWithErrors
62
-
"""
57
+
FSharp """
63
58
type Foo(x : int) =
64
59
member v.MyX() = x
65
60
66
61
let foo =
67
62
{ new Foo(3)
68
63
with
69
64
member v.MyX() = 4 }
70
-
"""
71
-
[|
72
-
FSharpErrorSeverity.Error,767,(8,16,8,23),"The type Foo contains the member 'MyX' but it is not a virtual or abstract method that is available to override or implement."
73
-
FSharpErrorSeverity.Error,17,(8,18,8,21),"The member 'MyX : unit -> int' does not have the correct type to override any given virtual method"
74
-
FSharpErrorSeverity.Error,783,(6,11,6,14),"At least one override did not correctly implement its corresponding abstract member"
75
-
|]
65
+
"""
66
+
|> typecheck
67
+
|> shouldFail
68
+
|> withDiagnostics [
69
+
(Error 767, Line 8, Col 16, Line 8, Col 23,"The type Foo contains the member 'MyX' but it is not a virtual or abstract method that is available to override or implement.")
70
+
(Error 17, Line 8, Col 18, Line 8, Col 21,"The member 'MyX : unit -> int' does not have the correct type to override any given virtual method")
71
+
(Error 783, Line 6, Col 11, Line 6, Col 14,"At least one override did not correctly implement its corresponding abstract member")]
76
72
77
73
[<Fact>]
78
74
let``No Matching Abstract Method With Same Name``()=
79
-
CompilerAssert.TypeCheckWithErrors
80
-
"""
75
+
FSharp """
81
76
type IInterface =
82
77
abstract MyFunction : int32 * int32 -> unit
83
78
abstract SomeOtherFunction : int32 * int32 -> unit
@@ -86,42 +81,43 @@ let x =
86
81
{ new IInterface with
87
82
member this.Function (i, j) = ()
88
83
}
89
-
"""
90
-
[|
91
-
FSharpErrorSeverity.Error,767,(8,14,8,34),"The member 'Function' does not correspond to any abstract or virtual method available to override or implement. Maybe you want one of the following:"+ System.Environment.NewLine +" MyFunction"
92
-
FSharpErrorSeverity.Error,17,(8,19,8,27),"The member 'Function : 'a * 'b -> unit' does not have the correct type to override any given virtual method"
93
-
FSharpErrorSeverity.Error,366,(7,3,9,4),"No implementation was given for those members: "+ System.Environment.NewLine +"\t'abstract member IInterface.MyFunction : int32 * int32 -> unit'"+ System.Environment.NewLine +"\t'abstract member IInterface.SomeOtherFunction : int32 * int32 -> unit'"+ System.Environment.NewLine +"Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'."
94
-
FSharpErrorSeverity.Error,783,(7,9,7,19),"At least one override did not correctly implement its corresponding abstract member"
95
-
|]
84
+
"""
85
+
|> typecheck
86
+
|> shouldFail
87
+
|> withDiagnostics [
88
+
(Error 767, Line 8, Col 14, Line 8, Col 34,"The member 'Function' does not correspond to any abstract or virtual method available to override or implement. Maybe you want one of the following:"+ System.Environment.NewLine +" MyFunction")
89
+
(Error 17, Line 8, Col 19, Line 8, Col 27,"The member 'Function : 'a * 'b -> unit' does not have the correct type to override any given virtual method")
90
+
(Error 366, Line 7, Col 3, Line 9, Col 4,"No implementation was given for those members: "+ System.Environment.NewLine +"\t'abstract member IInterface.MyFunction : int32 * int32 -> unit'"+ System.Environment.NewLine +"\t'abstract member IInterface.SomeOtherFunction : int32 * int32 -> unit'"+ System.Environment.NewLine +"Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.")
91
+
(Error 783, Line 7, Col 9, Line 7, Col 19,"At least one override did not correctly implement its corresponding abstract member")]
96
92
97
93
[<Fact>]
98
94
let``Member Has Multiple Possible Dispatch Slots``()=
99
-
CompilerAssert.TypeCheckWithErrors
100
-
"""
95
+
FSharp """
101
96
type IOverload =
102
97
abstract member Bar : int -> int
103
98
abstract member Bar : double -> int
104
99
105
100
type Overload =
106
101
interface IOverload with
107
102
override __.Bar _ = 1
108
-
"""
109
-
[|
110
-
FSharpErrorSeverity.Error,366,(7,15,7,24),"No implementation was given for those members: "+ System.Environment.NewLine +"\t'abstract member IOverload.Bar : double -> int'"+ System.Environment.NewLine +"\t'abstract member IOverload.Bar : int -> int'"+ System.Environment.NewLine +"Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'."
111
-
FSharpErrorSeverity.Error,3213,(8,21,8,24),"The member 'Bar<'a0> : 'a0 -> int' matches multiple overloads of the same method.\nPlease restrict it to one of the following:"+ System.Environment.NewLine +" Bar : double -> int"+ System.Environment.NewLine +" Bar : int -> int."
112
-
|]
103
+
"""
104
+
|> typecheck
105
+
|> shouldFail
106
+
|> withDiagnostics [
107
+
(Error 366, Line 7, Col 15, Line 7, Col 24,"No implementation was given for those members: "+ System.Environment.NewLine +"\t'abstract member IOverload.Bar : double -> int'"+ System.Environment.NewLine +"\t'abstract member IOverload.Bar : int -> int'"+ System.Environment.NewLine +"Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.")
108
+
(Error 3213, Line 8, Col 21, Line 8, Col 24,"The member 'Bar<'a0> : 'a0 -> int' matches multiple overloads of the same method.\nPlease restrict it to one of the following:"+ System.Environment.NewLine +" Bar : double -> int"+ System.Environment.NewLine +" Bar : int -> int.")]
113
109
114
110
[<Fact>]
115
111
let``Do Cannot Have Visibility Declarations``()=
116
-
CompilerAssert.ParseWithErrors
117
-
"""
112
+
FSharp """
118
113
type X() =
119
114
do ()
120
115
private do ()
121
116
static member Y() = 1
122
-
"""
123
-
[|
124
-
FSharpErrorSeverity.Error,531,(4,5,4,12),"Accessibility modifiers should come immediately prior to the identifier naming a construct"
125
-
FSharpErrorSeverity.Error,512,(4,13,4,18),"Accessibility modifiers are not permitted on 'do' bindings, but 'Private' was given."
126
-
FSharpErrorSeverity.Error,222,(2,1,3,1),"Files in libraries or multiple-file applications must begin with a namespace or module declaration, e.g. 'namespace SomeNamespace.SubNamespace' or 'module SomeNamespace.SomeModule'. Only the last source file of an application may omit such a declaration."
127
-
|]
117
+
"""
118
+
|> parse
119
+
|> shouldFail
120
+
|> withDiagnostics [
121
+
(Error 531, Line 4, Col 5, Line 4, Col 12,"Accessibility modifiers should come immediately prior to the identifier naming a construct")
122
+
(Error 512, Line 4, Col 13, Line 4, Col 18,"Accessibility modifiers are not permitted on 'do' bindings, but 'Private' was given.")
123
+
(Error 222, Line 2, Col 1, Line 3, Col 1,"Files in libraries or multiple-file applications must begin with a namespace or module declaration, e.g. 'namespace SomeNamespace.SubNamespace' or 'module SomeNamespace.SomeModule'. Only the last source file of an application may omit such a declaration.")]
0 commit comments