Open DragonSA opened 1 year ago
This is not currently supported by the F# tooling. In particular TryBindMethInfoAttribute
is incomplete for provided methods:
From fsharp\src\Compiler\Checking\AttributeChecking.fs
:
let TryBindMethInfoAttribute g (m: range) (AttribInfo(atref, _) as attribSpec) minfo f1 f2 f3 =
#if NO_TYPEPROVIDERS
// to prevent unused parameter warning
ignore f3
#endif
BindMethInfoAttributes m minfo
(fun ilAttribs -> TryDecodeILAttribute atref ilAttribs |> Option.bind f1)
(fun fsAttribs -> TryFindFSharpAttribute g attribSpec fsAttribs |> Option.bind f2)
#if !NO_TYPEPROVIDERS
(fun provAttribs ->
match provAttribs.PUntaint((fun a -> a.GetAttributeConstructorArgs(provAttribs.TypeProvider.PUntaintNoFailure(id), atref.FullName)), m) with
| Some args -> f3 args
| None -> None)
#else
(fun _provAttribs -> None)
If you'd like to help address this problem, please submit a PR to dotnet/fsharp
Description
Using a generative type provider fails to create a computation expression builder with a custom operation. The compiler fails to recognise the method as a custom operation.
Note that the IL appears to be practically equivalent for the generated type and the manually created builder (that does compile successfully).
Repro steps
See the repo ProvidedCustomOperation for a minimal reproduction. Key snippets below:
The generative type provider that creates a computation expression builder with a custom operation defined.
The equivalent builder:
Expected behavior
The computation expression compiles successfully:
Actual behavior
Compilation error:
Related information