Implicit Action/Func conversion captures extra expressions
Open
Area-Compiler-CodeGen
Area-Diagnostics
Bug
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 22h
- Merged PRs (30d)
- 144
Description
**Repro steps**
```fsharp
let x (f: System.Action) =
f.Invoke 99
f.Invoke 98
printfn "here"
let y () =
printfn "one time"
fun num -> printfn "%d" num
x (y ())
```
**Expected behavior**
Prints
```
one time
99
98
here
```
which is what would've been printed with `(f: int -> unit)` instead of `Action`
**Actual behavior**
Prints
```
one time
99
one time
98
here
```
because `x (y ())` is unexpectedly(?) expanded into `x (Action (fun num -> y () num))`.
**Known workarounds**
Bind `y ()` first, manually wrap `fun num ...` in an `Action`, etc.
**Related information**
* SDK 10.0.100-rc.1.25451.107
Contributor guide
Assessment
This issue has not been assessed yet.