Type is not inferred automatically in CE function .Yield parameter when other overloads are present
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
Description
I'm building a library that heavily depends on .Yield overloads in CE. I've found the case when it is expected for the type to get inferred automatically, however it is not
**Repro steps**
```fsharp
open System
type Test() =
member inline _.Yield(value: int -> unit) = ignore
member inline _.Yield(value: string) = ignore // without this overload issue is not observed
member inline _.Zero() = ignore
let x =
Test() {
yield (fun y -> Console.WriteLine(y))
}
```
**Expected behavior**
I expect the code above to compile since the `y` type should be inferred to `int`.
**Actual behavior**
Compilation error, since `y` requires specifying type explicitly.
```
error FS0041: A unique overload for method 'WriteLine' could not be determined based on type information prior to this program point. A type annotation may be needed.
Known type of argument: 'a
Candidates:
- Console.WriteLine(buffer: char array) : unit
- Console.WriteLine(format: string, [] arg: obj array) : unit
- Console.WriteLine(value: bool) : unit
- Console.WriteLine(value: char) : unit
- Console.WriteLine(value: decimal) : unit
- Console.WriteLine(value: float) : unit
- Console.WriteLine(value: float32) : unit
- Console.WriteLine(value: int) : unit
- Console.WriteLine(value: int64) : unit
- Console.WriteLine(value: obj) : unit
- Console.WriteLine(value: string) : unit
- Console.WriteLine(value: uint32) : unit
- Console.WriteLine(value: uint64) : unit
```
**Known workarounds**
Specify `y` type explicitly
**Related information**
```
.NET SDK:
Version: 9.0.100-rc.1.24452.12
Commit: 81a714c6d3
Workload version: 9.0.100-manifests.67cd1eb6
MSBuild version: 17.12.0-preview-24422-09+d17ec720d
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22631
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\9.0.100-rc.1.24452.12\
```
Contributor guide
Assessment
This issue has not been assessed yet.