Skip to content

Commit

Permalink
proposed work around the flaky error message until dotnet#6725 has a fix
Browse files Browse the repository at this point in the history
we keep the fsharpqa test around (but removing the overload error messages from what is asserted out of it) in the meantime
  • Loading branch information
smoothdeveloper committed Jan 22, 2020
1 parent b82ed30 commit 67fc801
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,48 +1,32 @@

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)'

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'.

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.

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.

E_LessThanDotOpenParen001.fsx(26,12,26,15): typecheck error FS0043: No overloads match for method 'op_PlusPlusPlus'.
E_LessThanDotOpenParen001.fsx(23,12,23,15): typecheck error FS0043: No overloads match for method 'op_PlusPlusPlus'.

Known return type: ^a

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

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

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

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

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

E_LessThanDotOpenParen001.fsx(29,44,29,54): typecheck error FS0001: This expression was expected to have type
'int'
but here has type
'string'

E_LessThanDotOpenParen001.fsx(29,10,29,68): typecheck error FS0041: No overloads match for method 'op_PlusPlusPlus'.
E_LessThanDotOpenParen001.fsx(26,10,26,68): typecheck error FS0041: No overloads match for method 'op_PlusPlusPlus'.

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

Available overloads:
- static member TestType.( +++ ) : a:'T * b:TestType<'T,'S> -> 'T // Argument 'a' doesn't match
- static member TestType.( +++ ) : a:(int -> 'T) * b:TestType<'T,int> -> ^a when ^T1 : (static member ( + ) : ^T1 * ^T1 -> ^a) // Argument 'b' doesn't match
- static member TestType.( +++ ) : a:TestType<'T,'S> * b:'T -> 'T // Argument 'a' doesn't match
- static member TestType.( +++ ) : a:TestType<'T,'S> * b:('T -> 'S) -> 'T // Argument 'a' doesn't match
- static member TestType.( +++ ) : a:TestType<'T,'S> * b:TestType<'T,'S> -> 'T // Argument 'a' doesn't match
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
// #Regression #Conformance #LexicalAnalysis #Operators
// Regression test for FSHARP1.0:4805
// We are not really after the actual error messages here (some of them have been omitted), rather we
// want to verify we do not crash!

type public TestType<'T,'S>() =

member public s.Value with get() = Unchecked.defaultof<'T>
static member public (+++) (a : TestType<'T,'S>, b : TestType<'T,'S>) = a.Value
static member public (+++) (a : TestType<'T,'S>, b : 'T) = b
static member public (+++) (a : 'T, b : TestType<'T,'S>) = a
static member public (+++) (a : TestType<'T,'S>, b : 'T -> 'S) = a.Value
static member public (+++) (a : 'S -> 'T, b : TestType<'T,'S>) = (a 17) + b.Value

// this is triggering https://github.com/dotnet/fsharp/issues/6725 and make the error reported by compiler flaky
//static member public (+++) (a : 'S -> 'T, b : TestType<'T,'S>) = (a 17) + b.Value

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

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

module ``error messages using BCL``=
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// #Regression #Conformance #LexicalAnalysis #Operators
// Regression test for FSHARP1.0:4805
// We are not really after the actual error messages here (some of them have been omitted), rather we
// want to verify we do not crash!
//<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>
//<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>

type public TestType<'T,'S>() =

member public s.Value with get() = Unchecked.defaultof<'T>
static member public (+++) (a : TestType<'T,'S>, b : TestType<'T,'S>) = a.Value
static member public (+++) (a : TestType<'T,'S>, b : 'T) = b
static member public (+++) (a : 'T, b : TestType<'T,'S>) = a
static member public (+++) (a : TestType<'T,'S>, b : 'T -> 'S) = a.Value
static member public (+++) (a : 'S -> 'T, b : TestType<'T,'S>) = (a 17) + b.Value

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

let tt0 = TestType<int, string>()
let tt1 = TestType<int, string>()

let f (x : string) = 18

let a0 = tt0 +++ tt1
let a1 = tt0 +++ 11
let a2 = 12 +++ tt1
let a3 = tt0 +++ (fun x -> "18")
let a4 = f +++ tt0

let a5 = TestType<int, string>.(+++)(f, tt0)
let a6 = TestType<int, string>.(+++)((fun (x : string) -> 18), tt0)
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
SOURCE=GreaterThanDotParen01.fs COMPILE_ONLY=1 # GreaterThanDotParen01.fs
SOURCE=E_GreaterThanDotParen01.fs COMPILE_ONLY=1 # E_GreaterThanDotParen01.fs

SOURCE=E_LessThanDotOpenParen001.fs COMPILE_ONLY=1 SCFLAGS=--flaterrors # E_LessThanDotOpenParen001.fs
SOURCE=LessThanDotOpenParen001.fs COMPILE_ONLY=1 # LessThanDotOpenParen001.fs

SOURCE=GreaterThanColon001.fs COMPILE_ONLY=1 # GreaterThanColon001.fs
Expand Down

0 comments on commit 67fc801

Please sign in to comment.