public enum Test { Yes, No }
I have these two switch
expressions. The one below gives a CS8509 warning:
Test? test = null;
var result = test switch
{
null => "Null",
Test.Yes => "Yes",
Test.No => "No",
};
But moving the null
case to the end resolves it. Does anybody know why this happens? This has to be a bug, correct?
Test? test = null;
var result = test switch
{
Test.Yes => "Yes",
Test.No => "No",
null => "Null",
};
Project settings:
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>10.0</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NoWarn>8524</NoWarn>
</PropertyGroup>