A parenthesized unit literal () → (()) is required as an argument pattern when overriding/implementing a generic method where unit is the generic type argument.
Repro steps
Provide the steps required to reproduce the problem:
- Define an abstract method whose single argument is a generic type (
abstract M : 'T -> …).
- When implementing or overriding the method when the generic type parameter is
unit, the argument pattern must be (()); using only () yields error FS0768: The member 'M' does not accept the correct number of arguments. 1 argument(s) are expected, but 0 were given.
Single () usually means unit
type C = abstract M : unit -> unit
let _ = { new C with override _.M () = () }
Double (()) is required when overriding/implementing a generic method where unit is the generic type argument
Double (()) compiles:
type C<'T> = abstract M : 'T -> unit
let _ = { new C<unit> with override _.M (()) = () }
but not ():
let _ = { new C<unit> with override _.M () = () }
------------------------------------^^^^^^
stdin(3,37): error FS0768: The member 'M' does not accept the correct number of arguments. 1 argument(s) are expected, but 0 were given. The required signature is 'C.M: 'T -> unit'.
even though this is fine:
type C<'T> = abstract M : 'T * 'T -> unit
let c = { new C<unit> with override _.M ((), ()) = () }
as is
type C<'T> = abstract M : 'T -> 'T -> unit
let c = { new C<unit> with override _.M () () = () }
Expected behavior
() should mean unit everywhere.
Actual behavior
(()) is required to represent unit in certain scenarios.
Known workarounds
N/A.
Related information
.NET SDK 8.0.100-rc.2.23502.2 (and probably going far back—I remember running into this in years past).
A parenthesized unit literal
()→(())is required as an argument pattern when overriding/implementing a generic method whereunitis the generic type argument.Repro steps
Provide the steps required to reproduce the problem:
abstract M : 'T -> …).unit, the argument pattern must be(()); using only()yieldserror FS0768: The member 'M' does not accept the correct number of arguments. 1 argument(s) are expected, but 0 were given.Single
()usually meansunitDouble
(())is required when overriding/implementing a generic method whereunitis the generic type argumentDouble
(())compiles:but not
():even though this is fine:
as is
Expected behavior
()should meanuniteverywhere.Actual behavior
(())is required to representunitin certain scenarios.Known workarounds
N/A.
Related information
.NET SDK 8.0.100-rc.2.23502.2 (and probably going far back—I remember running into this in years past).