You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please provide a succinct description of the issue.
Repro steps
openSystem.Threading.TasksletmyFunction(f,i)=task{do! f ""return()}[<EntryPoint>]letmain argv =letmyTuple=(fun s -> Task.FromResult()),1(myFunction myTuple).Wait()0
Expected behavior
The programs runs to end successfully. This code worked with Fsharp 5.0.1 and TaskBuilder.fs
Actual behavior
With Fsharp.Core 6.0 it fails in runtime with error
Unhandled exception. System.InvalidCastException: Unable to cast object of type 'System.Tuple`2[Microsoft.FSharp.Core.FSharpFunc`2[System.String,System.Threading.Tasks.Task`1[Microsoft.FSharp.Core.Unit]],System.Int32]' to type 'S
ystem.Tuple`2[Microsoft.FSharp.Core.FSharpFunc`2[System.String,System.Threading.Tasks.Task`1[Microsoft.FSharp.Core.Unit]],System.Object]'.
Known workarounds
It works when f or i parameter has type annotation
Related information
Provide any related information (optional):
Windows 10
Microsoft (R) Build Engine version 17.0.0-preview-21460-01+8f208e609 for .NET
Jetbrains Rider
The text was updated successfully, but these errors were encountered:
dsyme
changed the title
Runtime cast failure after updating to Fsharp.Core 6.0
Runtime cast failure using tasks in F# 6.0
Sep 27, 2021
dsyme
changed the title
Runtime cast failure using tasks in F# 6.0
Task code requries additional type annotations (was : Runtime cast failure using tasks in F# 6.0 )
Sep 27, 2021
Thanks for this bug report. I've changed the title.
The underlying problem here is the use of SRTP for "task-like" constructs in F# 6.0, which is hitting problems associated right back to the mis-inclusion of #1650 into F#. I will find a suitable fix for this and we will also be adjuting SRTP to fully remove #1650 in F# vNext, one way or another.
It will take a while for that fix to come through the works. In the meantime you should indeed add type annotations to places where the types of tasks being executed by do! or let! is not simply determined. For example
letmyFunction(f:string ->Task<_>,i)=task{do! f ""return()}
Please provide a succinct description of the issue.
Repro steps
Expected behavior
The programs runs to end successfully. This code worked with Fsharp 5.0.1 and TaskBuilder.fs
Actual behavior
With Fsharp.Core 6.0 it fails in runtime with error
Known workarounds
It works when f or i parameter has type annotation
Related information
Provide any related information (optional):
The text was updated successfully, but these errors were encountered: