The following code does not compile.
type A(?arg) =
member __.Arg : string option = arg
type B(?arg) =
inherit A(arg) //ERROR expected type string but has type 'a option
I assume this is because an instance of the underlying type of the option must be provided, and the compiler handles passing Some
/None
based on syntax.
Assuming my assumption has been correctly assumed, is there a workaround for this? Is it possible to propagate optional arguments?
F# spec 8.13.5 Optional arguments to method members
By using normal, unnamed arguments matched by position.
Sorry had to test it first: it seems you are right - you have to do the "?" for A yourself: