Unexpected warning `The default value does not have the same type as the argument`
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
Description
**Repro steps**
Consider the following code
```fsharp
open System
open System.Runtime.InteropServices
open System.Threading
type Bar() =
let consumeToken (ct: CancellationToken) = ()
member _.Foo(s: string, [] ct) =
consumeToken ct
Unchecked.defaultof
member x.Foo(i: int, [] ct) =
let s = i.ToString()
x.Foo(s, ct)
```
For second overload compiler produces warning `FS3211: The default value does not have the same type as the argument. The DefaultParameterValue attribute and any Optional attribute will be ignored. Note: 'null' needs to be annotated with the correct type, e.g. 'DefaultParameterValue(null:obj)'.`
`ct` is of type `CancellationToken` and also gets compiled to it. The warning seems redundant. It's possible to get rid of the warning by specifying type explicitly `ct: CancellationToken`.
**Expected behavior**
No warning issued.
**Actual behavior**
Seemingly unnecessary warning.
**Known workarounds**
Provide type explicitly.
**Related information**
.NET SDK 9.0.102
Contributor guide
Assessment
This issue has not been assessed yet.