Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tests/fsharp/conformance/expressions/syntacticsugar/E_Slices01.bsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

E_Slices01.fsx(22,9,22,19): typecheck error FS0041: A unique overload for method 'GetSlice' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: member Foo.GetSlice : x:int * y1:int option * y2:float option -> unit, member Foo.GetSlice : x:int * y1:int option * y2:int option -> unit

E_Slices01.fsx(23,9,23,17): typecheck error FS0041: A unique overload for method 'GetSlice' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: member Foo.GetSlice : x:int * y1:int option * y2:float option -> unit, member Foo.GetSlice : x:int * y1:int option * y2:int option -> unit

E_Slices01.fsx(24,9,24,19): typecheck error FS0041: A unique overload for method 'GetSlice' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: member Foo.GetSlice : x1:float option * x2:int option * y:int -> unit, member Foo.GetSlice : x1:int option * x2:int option * y:int -> unit

E_Slices01.fsx(25,9,25,17): typecheck error FS0041: A unique overload for method 'GetSlice' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: member Foo.GetSlice : x1:float option * x2:int option * y:int -> unit, member Foo.GetSlice : x1:int option * x2:int option * y:int -> unit

E_Slices01.fsx(26,9,26,17): typecheck error FS0039: The field, constructor or member 'Item' is not defined.

E_Slices01.fsx(27,9,27,26): typecheck error FS0503: A member or object constructor 'GetSlice' taking 4 arguments is not accessible from this code location. All accessible versions of method 'GetSlice' take 3 arguments.

E_Slices01.fsx(28,9,28,20): typecheck error FS0503: A member or object constructor 'GetSlice' taking 5 arguments is not accessible from this code location. All accessible versions of method 'GetSlice' take 3 arguments.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

E_LeftToRightOverloadResolution01.fsx(7,23,7,51): typecheck error FS0041: A unique overload for method 'WriteLine' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: System.Console.WriteLine(buffer: char []) : unit, System.Console.WriteLine(format: string, [<System.ParamArray>] arg: obj []) : unit, System.Console.WriteLine(value: bool) : unit, System.Console.WriteLine(value: char) : unit, System.Console.WriteLine(value: decimal) : unit, System.Console.WriteLine(value: float) : unit, System.Console.WriteLine(value: float32) : unit, System.Console.WriteLine(value: int) : unit, System.Console.WriteLine(value: int64) : unit, System.Console.WriteLine(value: obj) : unit, System.Console.WriteLine(value: string) : unit, System.Console.WriteLine(value: uint32) : unit, System.Console.WriteLine(value: uint64) : unit

E_LeftToRightOverloadResolution01.fsx(9,23,9,51): typecheck error FS0041: A unique overload for method 'WriteLine' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: System.Console.WriteLine(buffer: char []) : unit, System.Console.WriteLine(format: string, [<System.ParamArray>] arg: obj []) : unit, System.Console.WriteLine(value: bool) : unit, System.Console.WriteLine(value: char) : unit, System.Console.WriteLine(value: decimal) : unit, System.Console.WriteLine(value: float) : unit, System.Console.WriteLine(value: float32) : unit, System.Console.WriteLine(value: int) : unit, System.Console.WriteLine(value: int64) : unit, System.Console.WriteLine(value: obj) : unit, System.Console.WriteLine(value: string) : unit, System.Console.WriteLine(value: uint32) : unit, System.Console.WriteLine(value: uint64) : unit
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// #Regression #TypeInference
// Regression for FSHARP1.0:5749
// Better error message for overload resolution to help ease pain associated with mismatch of intellisense information


let array = [| "Ted"; "Katie"; |]
Array.iter (fun it -> System.Console.WriteLine(it))

Array.iter (fun it -> System.Console.WriteLine(it)) array

array |> Array.iter (fun it -> System.Console.WriteLine(it))

4 changes: 4 additions & 0 deletions tests/fsharp/conformance/inference/E_OneTypeVariable03.bsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

E_OneTypeVariable03.fsx(60,34,60,44): typecheck error FS0041: A unique overload for method 'M' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member C23.M : x:'a * y:'b -> Two, static member C23.M : x:'a * y:int -> Three

E_OneTypeVariable03.fsx(61,34,61,45): typecheck error FS0041: A unique overload for method 'M' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member C123.M : x:'a * y:'a -> One, static member C123.M : x:'a * y:'b -> Two, static member C123.M : x:'a * y:int -> Three
62 changes: 62 additions & 0 deletions tests/fsharp/conformance/inference/E_OneTypeVariable03.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// #Regression #TypeInference
// Regression test for FSHARP1.0:4758
// Type Inference
// Check Method Disambiguation When User Generic Variable Get Instantiated By Overload Resolution

// These different return types are used to determine which overload got chosen
type One = | One
type Two = | Two
type Three = | Three
type Four = | Four

// An unsealed type
type C() =
member x.P = 1

type C1 =
static member M<'a>(x:'a,y:'a) = One

type C2 =
static member M<'a,'b>(x:'a,y:'b) = Two

type C3 =
static member M<'a>(x:'a,y:int) = Three

type C4 =
static member M<'a>(x:'a,y:C) = Four

type C12 =
static member M<'a>(x:'a,y:'a) = One
static member M<'a,'b>(x:'a,y:'b) = Two

type C23 =
static member M<'a,'b>(x:'a,y:'b) = Two
static member M<'a>(x:'a,y:int) = Three

type C13 =
static member M<'a>(x:'a,y:'a) = One
static member M<'a>(x:'a,y:int) = Three

type C14 =
static member M<'a>(x:'a,y:'a) = One
static member M<'a>(x:'a,y:C) = Four

type C24 =
static member M<'a,'b>(x:'a,y:'b) = Two
static member M<'a>(x:'a,y:C) = Four

type C123 =
static member M<'a>(x:'a,y:'a) = One
static member M<'a,'b>(x:'a,y:'b) = Two
static member M<'a>(x:'a,y:int) = Three

type C1234 =
static member M<'a>(x:'a,y:'a) = One
static member M<'a,'b>(x:'a,y:'b) = Two
static member M<'a>(x:'a,y:int) = Three
static member M<'a>(x:'a,y:C) = Four

module M3 =
let gB23 (x:'a) (y:int) = C23.M(x,y) // expect: ambiguity error
let gB123 (x:'a) (y:int) = C123.M(x,y) // expect: ambiguous on 2,3

4 changes: 4 additions & 0 deletions tests/fsharp/conformance/inference/E_OneTypeVariable03rec.bsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

E_OneTypeVariable03rec.fsx(60,38,60,48): typecheck error FS0041: A unique overload for method 'M' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member C23.M : x:'a * y:'b -> Two, static member C23.M : x:'a * y:int -> Three

E_OneTypeVariable03rec.fsx(61,38,61,49): typecheck error FS0041: A unique overload for method 'M' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member C123.M : x:'a * y:'a -> One, static member C123.M : x:'a * y:'b -> Two, static member C123.M : x:'a * y:int -> Three
61 changes: 61 additions & 0 deletions tests/fsharp/conformance/inference/E_OneTypeVariable03rec.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// #Regression #TypeInference
// Regression test for FSHARP1.0:4758
// Type Inference
// Check Method Disambiguation When User Generic Variable Get Instantiated By Overload Resolution

// These different return types are used to determine which overload got chosen
type One = | One
type Two = | Two
type Three = | Three
type Four = | Four

// An unsealed type
type C() =
member x.P = 1

type C1 =
static member M<'a>(x:'a,y:'a) = One

type C2 =
static member M<'a,'b>(x:'a,y:'b) = Two

type C3 =
static member M<'a>(x:'a,y:int) = Three

type C4 =
static member M<'a>(x:'a,y:C) = Four

type C12 =
static member M<'a>(x:'a,y:'a) = One
static member M<'a,'b>(x:'a,y:'b) = Two

type C23 =
static member M<'a,'b>(x:'a,y:'b) = Two
static member M<'a>(x:'a,y:int) = Three

type C13 =
static member M<'a>(x:'a,y:'a) = One
static member M<'a>(x:'a,y:int) = Three

type C14 =
static member M<'a>(x:'a,y:'a) = One
static member M<'a>(x:'a,y:C) = Four

type C24 =
static member M<'a,'b>(x:'a,y:'b) = Two
static member M<'a>(x:'a,y:C) = Four

type C123 =
static member M<'a>(x:'a,y:'a) = One
static member M<'a,'b>(x:'a,y:'b) = Two
static member M<'a>(x:'a,y:int) = Three

type C1234 =
static member M<'a>(x:'a,y:'a) = One
static member M<'a,'b>(x:'a,y:'b) = Two
static member M<'a>(x:'a,y:int) = Three
static member M<'a>(x:'a,y:C) = Four

module M3Rec =
let rec gB23 (x:'a) (y:int) = C23.M(x,y) // expect: ambiguity error
let rec gB123 (x:'a) (y:int) = C123.M(x,y) // expect: ambiguous on 2,3
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

E_TwoDifferentTypeVariables01.fsx(61,33,61,43): typecheck error FS0041: A unique overload for method 'M' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member C13.M : x:'a * y:'a -> One, static member C13.M : x:'a * y:int -> Three

E_TwoDifferentTypeVariables01.fsx(62,33,62,43): typecheck error FS0041: A unique overload for method 'M' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member C24.M : x:'a * y:'b -> Two, static member C24.M : x:'a * y:C -> Four

E_TwoDifferentTypeVariables01.fsx(63,33,63,47): typecheck error FS0041: A unique overload for method 'M' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member C13.M : x:'a * y:'a -> One, static member C13.M : x:'a * y:int -> Three

E_TwoDifferentTypeVariables01.fsx(64,33,64,46): typecheck error FS0041: A unique overload for method 'M' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member C13.M : x:'a * y:'a -> One, static member C13.M : x:'a * y:int -> Three
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// #Regression #TypeInference
// Regression test for FSHARP1.0:4758
// Type Inference
// Check Method Disambiguation When User Generic Variable Get Instantiated By Overload Resolution

// These different return types are used to determine which overload got chosen
type One = | One
type Two = | Two
type Three = | Three
type Four = | Four

// An unsealed type
type C() =
member x.P = 1

type C1 =
static member M<'a>(x:'a,y:'a) = One

type C2 =
static member M<'a,'b>(x:'a,y:'b) = Two

type C3 =
static member M<'a>(x:'a,y:int) = Three

type C4 =
static member M<'a>(x:'a,y:C) = Four

type C12 =
static member M<'a>(x:'a,y:'a) = One
static member M<'a,'b>(x:'a,y:'b) = Two

type C23 =
static member M<'a,'b>(x:'a,y:'b) = Two
static member M<'a>(x:'a,y:int) = Three

type C13 =
static member M<'a>(x:'a,y:'a) = One
static member M<'a>(x:'a,y:int) = Three

type C14 =
static member M<'a>(x:'a,y:'a) = One
static member M<'a>(x:'a,y:C) = Four

type C24 =
static member M<'a,'b>(x:'a,y:'b) = Two
static member M<'a>(x:'a,y:C) = Four

type C123 =
static member M<'a>(x:'a,y:'a) = One
static member M<'a,'b>(x:'a,y:'b) = Two
static member M<'a>(x:'a,y:int) = Three

type C1234 =
static member M<'a>(x:'a,y:'a) = One
static member M<'a,'b>(x:'a,y:'b) = Two
static member M<'a>(x:'a,y:int) = Three
static member M<'a>(x:'a,y:C) = Four

module M1 =
// Errors
let gB13 (x:'a) (y:'b) = C13.M(x,y) // expect: ambiguity error (and note: both would instantiate 'a or 'b)
let gB24 (x:'a) (y:'b) = C24.M(x,y) = Four // expect: ambiguity error
let gC13 (x:'a) (y:'b) = C13.M<'a>(x,y) // expect: ambiguity error (and note: both would instantiate 'a or 'b)
let gD13 (x:'a) (y:'b) = C13.M<_>(x,y) // expect: ambiguity error (and note: both would instantiate 'a or 'b)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

E_TwoDifferentTypeVariables01rec.fsx(60,37,60,47): typecheck error FS0041: A unique overload for method 'M' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member C13.M : x:'a * y:'a -> One, static member C13.M : x:'a * y:int -> Three

E_TwoDifferentTypeVariables01rec.fsx(61,37,61,47): typecheck error FS0041: A unique overload for method 'M' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member C24.M : x:'a * y:'b -> Two, static member C24.M : x:'a * y:C -> Four

E_TwoDifferentTypeVariables01rec.fsx(62,37,62,51): typecheck error FS0041: A unique overload for method 'M' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member C13.M : x:'a * y:'a -> One, static member C13.M : x:'a * y:int -> Three

E_TwoDifferentTypeVariables01rec.fsx(63,37,63,50): typecheck error FS0041: A unique overload for method 'M' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member C13.M : x:'a * y:'a -> One, static member C13.M : x:'a * y:int -> Three
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// #Regression #TypeInference
// Regression test for FSHARP1.0:4758
// Type Inference
// Check Method Disambiguation When User Generic Variable Get Instantiated By Overload Resolution

// These different return types are used to determine which overload got chosen
type One = | One
type Two = | Two
type Three = | Three
type Four = | Four

// An unsealed type
type C() =
member x.P = 1

type C1 =
static member M<'a>(x:'a,y:'a) = One

type C2 =
static member M<'a,'b>(x:'a,y:'b) = Two

type C3 =
static member M<'a>(x:'a,y:int) = Three

type C4 =
static member M<'a>(x:'a,y:C) = Four

type C12 =
static member M<'a>(x:'a,y:'a) = One
static member M<'a,'b>(x:'a,y:'b) = Two

type C23 =
static member M<'a,'b>(x:'a,y:'b) = Two
static member M<'a>(x:'a,y:int) = Three

type C13 =
static member M<'a>(x:'a,y:'a) = One
static member M<'a>(x:'a,y:int) = Three

type C14 =
static member M<'a>(x:'a,y:'a) = One
static member M<'a>(x:'a,y:C) = Four

type C24 =
static member M<'a,'b>(x:'a,y:'b) = Two
static member M<'a>(x:'a,y:C) = Four

type C123 =
static member M<'a>(x:'a,y:'a) = One
static member M<'a,'b>(x:'a,y:'b) = Two
static member M<'a>(x:'a,y:int) = Three

type C1234 =
static member M<'a>(x:'a,y:'a) = One
static member M<'a,'b>(x:'a,y:'b) = Two
static member M<'a>(x:'a,y:int) = Three
static member M<'a>(x:'a,y:C) = Four

module M1Rec =
let rec gB13 (x:'a) (y:'b) = C13.M(x,y) // expect: ambiguity error (and note: both would instantiate 'a or 'b)
let rec gB24 (x:'a) (y:'b) = C24.M(x,y) = Four // expect: ambiguity error
let rec gC13 (x:'a) (y:'b) = C13.M<'a>(x,y) // expect: ambiguity error (and note: both would instantiate 'a or 'b)
let rec gD13 (x:'a) (y:'b) = C13.M<_>(x,y) // expect: ambiguity error (and note: both would instantiate 'a or 'b)
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

E_TwoDifferentTypeVariablesGen00rec.fsx(61,52,61,53): typecheck error FS0064: This construct causes code to be less generic than indicated by the type annotations. The type variable 'a has been constrained to be type ''b'.

E_TwoDifferentTypeVariablesGen00rec.fsx(61,18,61,42): typecheck error FS0064: This construct causes code to be less generic than indicated by the type annotations. The type variable 'b has been constrained to be type ''a'.

E_TwoDifferentTypeVariablesGen00rec.fsx(61,18,61,42): typecheck error FS0043: The type ''b' does not match the type ''b0'

E_TwoDifferentTypeVariablesGen00rec.fsx(62,52,62,53): typecheck error FS0064: This construct causes code to be less generic than indicated by the type annotations. The type variable 'b has been constrained to be type 'int'.

E_TwoDifferentTypeVariablesGen00rec.fsx(62,18,62,42): typecheck error FS0043: The type ''b' does not match the type 'int'

E_TwoDifferentTypeVariablesGen00rec.fsx(63,45,63,55): typecheck error FS0041: A unique overload for method 'M' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member C13.M : x:'a * y:'a -> One, static member C13.M : x:'a * y:int -> Three

E_TwoDifferentTypeVariablesGen00rec.fsx(64,56,64,57): typecheck error FS0064: This construct causes code to be less generic than indicated by the type annotations. The type variable 'a has been constrained to be type ''b'.

E_TwoDifferentTypeVariablesGen00rec.fsx(64,18,64,42): typecheck error FS0064: This construct causes code to be less generic than indicated by the type annotations. The type variable 'b has been constrained to be type ''a'.

E_TwoDifferentTypeVariablesGen00rec.fsx(64,18,64,42): typecheck error FS0043: The type ''b' does not match the type ''b0'

E_TwoDifferentTypeVariablesGen00rec.fsx(65,54,65,55): typecheck error FS0064: This construct causes code to be less generic than indicated by the type annotations. The type variable 'b has been constrained to be type ''a'.

E_TwoDifferentTypeVariablesGen00rec.fsx(65,56,65,57): typecheck error FS0064: This construct causes code to be less generic than indicated by the type annotations. The type variable 'a has been constrained to be type 'int'.

E_TwoDifferentTypeVariablesGen00rec.fsx(65,18,65,42): typecheck error FS0043: The type ''a' does not match the type 'int'

E_TwoDifferentTypeVariablesGen00rec.fsx(66,45,66,59): typecheck error FS0041: A unique overload for method 'M' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member C13.M : x:'a * y:'a -> One, static member C13.M : x:'a * y:int -> Three

E_TwoDifferentTypeVariablesGen00rec.fsx(67,55,67,56): typecheck error FS0064: This construct causes code to be less generic than indicated by the type annotations. The type variable 'a has been constrained to be type ''b'.

E_TwoDifferentTypeVariablesGen00rec.fsx(67,18,67,42): typecheck error FS0064: This construct causes code to be less generic than indicated by the type annotations. The type variable 'b has been constrained to be type ''a'.

E_TwoDifferentTypeVariablesGen00rec.fsx(67,18,67,42): typecheck error FS0043: The type ''b' does not match the type ''b0'

E_TwoDifferentTypeVariablesGen00rec.fsx(68,45,68,58): typecheck error FS0041: A unique overload for method 'M' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member C13.M : x:'a * y:'a -> One, static member C13.M : x:'a * y:int -> Three

E_TwoDifferentTypeVariablesGen00rec.fsx(69,55,69,56): typecheck error FS0064: This construct causes code to be less generic than indicated by the type annotations. The type variable 'b has been constrained to be type 'int'.

E_TwoDifferentTypeVariablesGen00rec.fsx(69,18,69,42): typecheck error FS0043: The type ''b' does not match the type 'int'
Loading