dotnet / dotnet/fsharp

Overload resolution does not eliminate incompatible Nullable candidates

Open
#13,731 0 comments 0 reactions 0 assignees View on GitHub
Area-Compiler-Checking Area-Compiler-Checking-Overloads Feature Request Needs-RFC
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

Found in https://github.com/dotnet/fsharp/pull/13673

```fs
type M() =
static member A(n: System.Nullable) = printfn "1"
static member A(n: int) = printfn "4"
let test(x: 'T) =
M.A(x)
```

If we know nothing we should prefer int, 'T should always be better than Nullable<'T>. Today we produce an ambiguity error.

https://sharplab.io/#v2:EYLgxg9gTgpgtADwGwBYA0AbEAzAzmgFxAEsMAfAgTwAcYACAWQAoBKOgXgFgAoOvu3AQCGBYmDoBbGBOAwodAIJMAdiDoBlSoOkA6AHIBXDBiHAMMADxgAFkKgA+NuzrUoxZQWzK6AIgCMPjz8AsKi4lIycooqau4ETi5uHl6+KIHc5gR0BDCCTAhqAOQAKk5B/Aw6SggsQA===

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.