fsprojects / FSharp.TypeProviders.SDK

The SDK for creating F# type providers
https://fsprojects.github.io/FSharp.TypeProviders.SDK/
MIT License
298 stars 94 forks source link

Splice Async quotation #277

Closed sergey-tihon closed 1 year ago

sergey-tihon commented 5 years ago

Description

The following provided method does not compile. It tries to splice quotation inside async CE

        let meth = ProvidedMethod("SpliceMethod", [], typeof<Async<string>>, isStatic=false, 
                    invokeCode = (fun args -> 
                        let v1A = <@ async {return "1"} @>
                        <@@
                            async {
                                let! v1 = %v1A
                                return v1 + "2"
                            }
                        @@>
                    ))

Repro steps

Please provide the steps required to reproduce the problem

  1. Checkout repo https://github.com/sergey-tihon/tp-splice-bug

  2. dotnet build

Expected behavior

Should compile

Actual behavior

Compilation of tests project fails with error

/Users/sergey/github/tp-temp/LemonadeSpliceProvider/tests/LemonadeSpliceProvider.Tests/LemonadeSpliceProvider.Tests.fs(7,20): error FS3033: The type provider 'LemonadeSpliceProviderImplementation+BasicGenerativeProvider' reported an error: The method or operation is not implemented. [/Users/sergey/github/tp-temp/LemonadeSpliceProvider/tests/LemonadeSpliceProvider.Tests/LemonadeSpliceProvider.Tests.fsproj]

Known workarounds

Splice outside of async CE

        let meth = ProvidedMethod("SpliceMethod", [], typeof<Async<string>>, isStatic=false, 
                    invokeCode = (fun args -> 
                        let v1A = <@ async {return "1"} @>
                        <@@
                            let temp = %v1A
                            async {
                                let! v1 = temp
                                return v1 + "2"
                            }
                        @@>
                    ))

Related information

kevmal commented 1 year ago

This now seems to compile