Unexpected warning The default value does not have the same type as the argument
#18312
Labels
Area-Compiler-Checking
Type checking, attributes and all aspects of logic checking
Bug
Impact-Medium
(Internal MS Team use only) Describes an issue with moderate impact on existing code.
Milestone
Repro steps
Consider the following code
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 typeCancellationToken
and also gets compiled to it. The warning seems redundant. It's possible to get rid of the warning by specifying type explicitlyct: CancellationToken
.Expected behavior
No warning issued.
Actual behavior
Seemingly unnecessary warning.
Known workarounds
Provide type explicitly.
Related information
.NET SDK 9.0.102
The text was updated successfully, but these errors were encountered: