-
Notifications
You must be signed in to change notification settings - Fork 833
Description
What
The values object expressions inside the definitions of failingExample1 and failingExample2 both fail to compile with the error message (on hover) The override for 'Overloaded : int -> bool' was ambiguous:
type IExample =
abstract member Overloaded : string -> bool
abstract member Overloaded : int -> bool
let workingExample1 (x : bool) =
{ new IExample with
member __.Overloaded (_ : string) = x
member __.Overloaded (_ : int) = x }
let workingExample2 x =
{ new IExample with
member __.Overloaded (_ : string) : bool = x
member __.Overloaded (_ : int) : bool = x }
let failingExample1 x =
{ new IExample with
member __.Overloaded (_ : string) = x
member __.Overloaded (_ : int) = x }
let failingExample2 (x : bool) =
{ new IExample with
member __.Overloaded value = x
member __.Overloaded value = x }Weirdly running the code in FSI gives different compiler error messages, namely:
error FS0017: The member 'Overloaded : string -> 'a' does not have the correct type to override any given virtual method for failingExample1
and
error FS0017: The member 'Overloaded : 'a -> bool' does not have the correct type to override any given virtual method for failingExample2.
It would be good to improve both messages in VS on hover and in FSI.
Why
Neither the error on hovering over the code in Visual Studio nor the compiler error message suggests how to fix the code.
How
Add a suggestion like Considered adding type annotations for the arguments and return type.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status