Closed eiriktsarpalis closed 7 years ago
This is a workaround:
type IFoo =
abstract Test : [<DefaultParameterValueAttribute(null:obj)>]?value:int -> string
Great, that works
The bug feels like it must be because we are failing to collect a type inference variable in the attribute argument in the "FindUnsolved.fs" code, roughly here: https://github.com/Microsoft/visualfsharp/blob/2d413fb940aa1677688454c50b8ec05cd3b6f78f/src/fsharp/FindUnsolved.fs#L178. However we are calling that function for custom attributes on parameters - and the function itself looks correct, so I'm not entirely clear where the bug is
One thing I notice that accExpr is not being called for the second "value-of-the-attribute" expression in each attribute, which may be relevant.
I think this is the root cause of https://github.com/Microsoft/visualfsharp/issues/1626
@eiriktsarpalis It's been a long time but finally tracked this one down https://github.com/Microsoft/visualfsharp/pull/3273
When writing APIs intended for C# consumption, it is common practice to attach the OptionalParameter and DefaultParameterValue attributes to any F# optional parameter (see also http://bugsquash.blogspot.gr/2012/08/optional-parameters-interop-c-f.html).
I have identified an issue where the compiler fails with an unhandled exception when attempting to attach these attributes to optional parameters defined in abstract methods. Here's a minimal reproduction:
This is
foo.fs
:And here is
bar.fs
:From the command line, running the following jobs:
Results in the following error: