-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Misleading diagnostic for constant false
when clause
#18750
Comments
Would it be okay for me to work on this? |
I realised that |
I misunderstood the requirement. It should also suggest different action based on the constant value..
|
We don't have warnings for the switch statement that are problematic, though they might be useful. Yes, I think we'd need to distinguish in our diagnostic between just the |
@elijah6 The diagnostic should use the C# name for the keyword |
Thank you @gafter . I will work on the warning part on this issue first and maybe look at the code gen part as well separately. I am assuming that, in the following case, the warning will be try
{
}
catch (SomeOtherException) when (false) // filter expression is a constant 'false'. Consider removing the catch clause
{
}
catch (Exception) when (false) // filter expression is a constant 'false'. Consider removing the catch clause
{
} try
{
}
catch (Exception) when (false) // filter expression is a constant 'false'. Consider removing the try-catch block
{
} |
Fixed in #18933 |
Version Used: 15.3 (master)
Steps to Reproduce:
Expected Behavior:
Warning: filter expression is constant 'false'; consider removing try-catch.
Actual Behavior:
Warning: filter expression is constant, consider removing the filter.
It would be a change of behavior to remove the filter as suggested by the diagnostic.
The text was updated successfully, but these errors were encountered: