Delegate creation from partially applied function doesn't respect side-effects
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
Description
I stumbled upon this problem when testing the [Observable.create](https://github.com/fsprojects/FSharp.Control.Reactive/blob/master/src/FSharp.Control.Reactive/Observable.fs#L128) method from the [FSharp.Control.Reactive](https://github.com/fsprojects/FSharp.Control.Reactive) repo. It is not working because of the behavior described below.
**Repro steps**
If we define the following functions:
```fsharp
let f s =
printfn "%s" s
fun () -> ()
let f_bad s = Action(f s)
let f_good s =
let m = f s
Action m
```
And then run:
```fsharp
f_bad "test_bad" |> ignore
f_good "test_good" |> ignore
```
the result is:
```
test_good
```
I would expect both test_bad and test_good to be printed in the output. Interestingly, both values are printed if we call .Invoke on the returned action method:
```fsharp
(f_bad "test_bad").Invoke()
(f_good "test_good").Invoke()
```
OS: Windows 10 1909
.NET Core
Tested in Visual Studio Code and in LINQPad 6
Contributor guide
Assessment
This issue has not been assessed yet.