-
Notifications
You must be signed in to change notification settings - Fork 833
Description
What
When overriding an abstract member like this:
type Base() =
abstract member Member: int * string -> string
default x.Member (i, s) = s
type Derived1() =
inherit Base()
override x.Member() = 5
type Derived2() =
inherit Base()
override x.Member (i : int) = "Hello"
type Derived3() =
inherit Base()
override x.Member (s : string, i : int) = sprintf "Hello %s" sFSI yields the error message
error FS0856: This override takes a different number of arguments to the corresponding abstract member
for the definitions in Derived1 and Derived2 and
error FS0001: This expression was expected to have type int but here has type string
for the definition in Derived3.
Why
The error message does not suggest the correct signature of the abstract methods so you don't know if you have them in the right order, etc. This can be quite a pain when inheriting from a class with a lot of members (such as a WPF Window) and trying to find the right overload.
How
In all 3 cases above, the error message should include the full type signature(s) for Member (including any overloads).
Bonus round
It would also be great to provide suggestions for members which can be overridden if the programmer has a typo in the method name, such as:
type Derived4() =
inherit Base()
override x.Memer (i, s) = sprintf "Hello %d" iThis currently produces the error:
error FS0855: No abstract or interface member was found that corresponds to this override