- 
                Notifications
    You must be signed in to change notification settings 
- Fork 834
Open
Labels
Area-Diagnosticsmistakes and possible improvements to diagnosticsmistakes and possible improvements to diagnosticsBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.(Internal MS Team use only) Describes an issue with limited impact on existing code.
Milestone
Description
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()yieldserror 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).
auduchinokedgarfgp
Metadata
Metadata
Assignees
Labels
Area-Diagnosticsmistakes and possible improvements to diagnosticsmistakes and possible improvements to diagnosticsBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.(Internal MS Team use only) Describes an issue with limited impact on existing code.