Skip to content

Commit b3f537f

Browse files
proposed work around the flaky error message until dotnet#6725 has a fix
we keep the fsharpqa test around (but removing the overload error messages from what is asserted out of it) in the meantime
1 parent eb26685 commit b3f537f

File tree

5 files changed

+42
-26
lines changed

5 files changed

+42
-26
lines changed
Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,32 @@
11

2-
E_LessThanDotOpenParen001.fsx(13,71,13,75): typecheck error FS0193: A type parameter is missing a constraint 'when ( ^T or ^?8151) : (static member ( + ) : ^T * ^?8151 -> ^?8152)'
3-
4-
E_LessThanDotOpenParen001.fsx(13,73,13,75): typecheck error FS0064: This construct causes code to be less generic than indicated by the type annotations. The type variable 'S has been constrained to be type 'int'.
5-
6-
E_LessThanDotOpenParen001.fsx(13,27,13,30): typecheck error FS1198: The generic member '( +++ )' has been used at a non-uniform instantiation prior to this program point. Consider reordering the members so this member occurs first. Alternatively, specify the full type of the member explicitly, including argument types, return type and any additional generic parameters and constraints.
7-
8-
E_LessThanDotOpenParen001.fsx(13,19,13,67): typecheck error FS0670: This code is not sufficiently generic. The type variable ^T when ^T : (static member ( + ) : ^T * ^T -> ^a) could not be generalized because it would escape its scope.
9-
10-
E_LessThanDotOpenParen001.fsx(26,12,26,15): typecheck error FS0043: No overloads match for method 'op_PlusPlusPlus'.
2+
E_LessThanDotOpenParen001.fsx(23,12,23,15): typecheck error FS0043: No overloads match for method 'op_PlusPlusPlus'.
113

124
Known return type: ^a
135

146
Known type parameters: < (string -> int) , TestType<int,string> >
157

168
Available overloads:
179
- static member TestType.( +++ ) : a:'T * b:TestType<'T,'S> -> 'T // Argument 'a' doesn't match
18-
- static member TestType.( +++ ) : a:(int -> 'T) * b:TestType<'T,int> -> ^a when ^T1 : (static member ( + ) : ^T1 * ^T1 -> ^a) // Argument 'a' doesn't match
1910
- static member TestType.( +++ ) : a:TestType<'T,'S> * b:'T -> 'T // Argument 'a' doesn't match
2011
- static member TestType.( +++ ) : a:TestType<'T,'S> * b:('T -> 'S) -> 'T // Argument 'a' doesn't match
2112
- static member TestType.( +++ ) : a:TestType<'T,'S> * b:TestType<'T,'S> -> 'T // Argument 'a' doesn't match
2213

23-
E_LessThanDotOpenParen001.fsx(28,10,28,45): typecheck error FS0041: No overloads match for method 'op_PlusPlusPlus'.
14+
E_LessThanDotOpenParen001.fsx(25,10,25,45): typecheck error FS0041: No overloads match for method 'op_PlusPlusPlus'.
2415

2516
Known types of arguments: (string -> int) * TestType<int,string>
2617

2718
Available overloads:
2819
- static member TestType.( +++ ) : a:'T * b:TestType<'T,'S> -> 'T // Argument 'a' doesn't match
29-
- static member TestType.( +++ ) : a:(int -> 'T) * b:TestType<'T,int> -> ^a when ^T1 : (static member ( + ) : ^T1 * ^T1 -> ^a) // Argument 'a' doesn't match
3020
- static member TestType.( +++ ) : a:TestType<'T,'S> * b:'T -> 'T // Argument 'a' doesn't match
3121
- static member TestType.( +++ ) : a:TestType<'T,'S> * b:('T -> 'S) -> 'T // Argument 'a' doesn't match
3222
- static member TestType.( +++ ) : a:TestType<'T,'S> * b:TestType<'T,'S> -> 'T // Argument 'a' doesn't match
3323

34-
E_LessThanDotOpenParen001.fsx(29,44,29,54): typecheck error FS0001: This expression was expected to have type
35-
'int'
36-
but here has type
37-
'string'
38-
39-
E_LessThanDotOpenParen001.fsx(29,10,29,68): typecheck error FS0041: No overloads match for method 'op_PlusPlusPlus'.
24+
E_LessThanDotOpenParen001.fsx(26,10,26,68): typecheck error FS0041: No overloads match for method 'op_PlusPlusPlus'.
4025

41-
Known types of arguments: (int -> 'a) * TestType<int,string>
26+
Known types of arguments: (string -> int) * TestType<int,string>
4227

4328
Available overloads:
4429
- static member TestType.( +++ ) : a:'T * b:TestType<'T,'S> -> 'T // Argument 'a' doesn't match
45-
- static member TestType.( +++ ) : a:(int -> 'T) * b:TestType<'T,int> -> ^a when ^T1 : (static member ( + ) : ^T1 * ^T1 -> ^a) // Argument 'b' doesn't match
4630
- static member TestType.( +++ ) : a:TestType<'T,'S> * b:'T -> 'T // Argument 'a' doesn't match
4731
- static member TestType.( +++ ) : a:TestType<'T,'S> * b:('T -> 'S) -> 'T // Argument 'a' doesn't match
4832
- static member TestType.( +++ ) : a:TestType<'T,'S> * b:TestType<'T,'S> -> 'T // Argument 'a' doesn't match

tests/fsharp/conformance/lexicalanalysis/E_LessThanDotOpenParen001.fsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
// #Regression #Conformance #LexicalAnalysis #Operators
2-
// Regression test for FSHARP1.0:4805
3-
// We are not really after the actual error messages here (some of them have been omitted), rather we
4-
// want to verify we do not crash!
5-
61
type public TestType<'T,'S>() =
72

83
member public s.Value with get() = Unchecked.defaultof<'T>
94
static member public (+++) (a : TestType<'T,'S>, b : TestType<'T,'S>) = a.Value
105
static member public (+++) (a : TestType<'T,'S>, b : 'T) = b
116
static member public (+++) (a : 'T, b : TestType<'T,'S>) = a
127
static member public (+++) (a : TestType<'T,'S>, b : 'T -> 'S) = a.Value
13-
static member public (+++) (a : 'S -> 'T, b : TestType<'T,'S>) = (a 17) + b.Value
8+
9+
// this is triggering https://github.com/dotnet/fsharp/issues/6725 and make the error reported by compiler flaky
10+
//static member public (+++) (a : 'S -> 'T, b : TestType<'T,'S>) = (a 17) + b.Value
1411

1512
let inline (+++) (a : ^a) (b : ^b) = ((^a or ^b): (static member (+++): ^a * ^b -> ^c) (a,b) )
1613

tests/fsharp/tests.fs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2901,6 +2901,9 @@ module OverloadResolution =
29012901
let [<Test>] ``Conformance\WellFormedness (E_Clashing_Values_in_AbstractClass01.fs)`` () = singleNegTest (testConfig "conformance/wellformedness") "E_Clashing_Values_in_AbstractClass01"
29022902
let [<Test>] ``Conformance\WellFormedness (E_Clashing_Values_in_AbstractClass03.fs)`` () = singleNegTest (testConfig "conformance/wellformedness") "E_Clashing_Values_in_AbstractClass03"
29032903
let [<Test>] ``Conformance\WellFormedness (E_Clashing_Values_in_AbstractClass04.fs)`` () = singleNegTest (testConfig "conformance/wellformedness") "E_Clashing_Values_in_AbstractClass04"
2904+
// note: this test still exist in fsharpqa to assert the compiler doesn't crash
2905+
// the part of the code generating a flaky error due to https://github.com/dotnet/fsharp/issues/6725
2906+
// is elided here to focus on overload resolution error messages
29042907
let [<Test>] ``Conformance\LexicalAnalysis\SymbolicOperators (E_LessThanDotOpenParen001.fs)`` () = singleNegTest (testConfig "conformance/lexicalanalysis") "E_LessThanDotOpenParen001"
29052908

29062909
module ``error messages using BCL``=
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// #Regression #Conformance #LexicalAnalysis #Operators
2+
// Regression test for FSHARP1.0:4805
3+
// We are not really after the actual error messages here (some of them have been omitted), rather we
4+
// want to verify we do not crash!
5+
//<Expects status="warning" id="FS0064">This construct causes code to be less generic than indicated by the type annotations\. The type variable 'S has been constrained to be type 'int'</Expects>
6+
//<Expects status="error" id="FS0670">This code is not sufficiently generic\. The type variable \^T when \^T : \(static member \( \+ \) : \^T \* \^T -> \^a\) could not be generalized because it would escape its scope</Expects>
7+
8+
type public TestType<'T,'S>() =
9+
10+
member public s.Value with get() = Unchecked.defaultof<'T>
11+
static member public (+++) (a : TestType<'T,'S>, b : TestType<'T,'S>) = a.Value
12+
static member public (+++) (a : TestType<'T,'S>, b : 'T) = b
13+
static member public (+++) (a : 'T, b : TestType<'T,'S>) = a
14+
static member public (+++) (a : TestType<'T,'S>, b : 'T -> 'S) = a.Value
15+
static member public (+++) (a : 'S -> 'T, b : TestType<'T,'S>) = (a 17) + b.Value
16+
17+
let inline (+++) (a : ^a) (b : ^b) = ((^a or ^b): (static member (+++): ^a * ^b -> ^c) (a,b) )
18+
19+
let tt0 = TestType<int, string>()
20+
let tt1 = TestType<int, string>()
21+
22+
let f (x : string) = 18
23+
24+
let a0 = tt0 +++ tt1
25+
let a1 = tt0 +++ 11
26+
let a2 = 12 +++ tt1
27+
let a3 = tt0 +++ (fun x -> "18")
28+
let a4 = f +++ tt0
29+
30+
let a5 = TestType<int, string>.(+++)(f, tt0)
31+
let a6 = TestType<int, string>.(+++)((fun (x : string) -> 18), tt0)

tests/fsharpqa/Source/Conformance/LexicalAnalysis/SymbolicOperators/env.lst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
SOURCE=GreaterThanDotParen01.fs COMPILE_ONLY=1 # GreaterThanDotParen01.fs
22
SOURCE=E_GreaterThanDotParen01.fs COMPILE_ONLY=1 # E_GreaterThanDotParen01.fs
33

4+
SOURCE=E_LessThanDotOpenParen001.fs COMPILE_ONLY=1 SCFLAGS=--flaterrors # E_LessThanDotOpenParen001.fs
45
SOURCE=LessThanDotOpenParen001.fs COMPILE_ONLY=1 # LessThanDotOpenParen001.fs
56

67
SOURCE=GreaterThanColon001.fs COMPILE_ONLY=1 # GreaterThanColon001.fs

0 commit comments

Comments
 (0)