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 }}
Repository navigation
Improve error reporting: ambiguous override method in object expression #1429
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:
typeIExample=abstractmemberOverloaded :string->boolabstractmemberOverloaded :int->boolletworkingExample1(x :bool)={new IExample withmember__.Overloaded(_ :string)= x
member__.Overloaded(_ :int)= x }letworkingExample2 x ={new IExample withmember__.Overloaded(_ :string):bool = x
member__.Overloaded(_ :int):bool = x }letfailingExample1 x ={new IExample withmember__.Overloaded(_ :string)= x
member__.Overloaded(_ :int)= x }letfailingExample2(x :bool)={new IExample withmember__.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.
Activity