-
Notifications
You must be signed in to change notification settings - Fork 833
Description
If you implement only one member of an interface with overloads without using specific typing you may well receive a very dubious error claiming your override has the wrong number of type parameters:
error FS0368: The member 'Bar<'a0> : 'a0 -> int' does not have the correct number of method type parameters. The required signature is 'Bar : double -> int'.
Repro steps
To see this in action, copy the following snippet into any F# project:
type IOverload =
abstract member Bar : int -> int
abstract member Bar : double -> int
type Overload =
interface IOverload with
override __.Bar _ = 1 // FS0368
Expected behavior
An error that explains what's going on. There are no type parameters here. Suggested text for error:
Ambiguous match: the generic method Bar matches multiple overloads of the same method, candidates are 'Bar : double -> int', 'Bar : int -> int'. Use a more specific type annotation for overriding the proper method.
Actual behavior
Actual behavior is that you see the following in the editor:
If you compile the project, you get a little more information, but it is still not covering the actual error:
error FS0368: The member 'Bar<'a0> : 'a0 -> int' does not have the correct number of method type parameters. The required signature is 'Bar : double -> int'.
error FS0368: The member 'Bar<'a0> : 'a0 -> int' does not have the correct number of method type parameters. The required signature is 'Bar : int -> int'.
error FS0017: The member 'Bar<'a0> : 'a0 -> int' does not have the correct type to override any given virtual method
Known workarounds
None (unless of course: learning what this error may mean and act on it).
Related information
Seen with:
- Windows 7
- .NET Runtime 4
- VS 2025
- F# 4.0
