Skip to content

Should static bool IsDefault<T>(T xx = default) => xx == default; compile? #35684

@yyjdelete

Description

@yyjdelete

Version Used:
sharplab.io(master/2.9.0)

Steps to Reproduce:
https://sharplab.io/#v2:EYLgtghgzgLgpgJwDQBMQGoA+ABADAAmwEYBuAWAChsBmQgJnwGF8BvS/DwogNn2AHt+AG3wBJKABE4AMwgBXITCIAeACoA+ABSr8AD134AvPhQz5igJRH1eg4eMA7BUPIVOXXgOFjJZhTDo1LR19IxM/S2tbfABLKHwnIRd2TmJPQRFxKVl/aiDtaONTHMjDG1D7cJKYV3cAejq0vgyfbPMYABZ8kLsq9qsywqKImG0LVwBfIA=

Expected Behavior:
https://github.com/dotnet/csharplang/blob/98043cdc889303d956d540d7ab3bc4f5044a9d3b/proposals/csharp-7.1/target-typed-default.md
xx == default should be the same as xx == default(T), and can't compile.

Actual Behavior:
xx == default is compile as xx == null without warns, and so default(T) == default is always false for struct.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions