-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
Area-IDEFeature - IDE0072Populate switch expressionPopulate switch expressionhelp wantedThe issue is "up for grabs" - add a comment if you are interested in working on itThe issue is "up for grabs" - add a comment if you are interested in working on it
Milestone
Description
Version Used: Compiler version: '4.12.0-3.24523.4 (f3348c2)'. Language version: latest (13.0).
Steps to Reproduce:
- Enable
EnforceCodeStyleInBuild - Set
AnalysisLeveltolatest-all - Use the following code:
#pragma warning disable IDE0008
#pragma warning disable IDE0059
char c = 'x';
bool i = false;
var x = (c, i) switch
{
('L', _) => '#',
('#', true) => 'L',
('#', false) => 'M',
(var z, _) => z,
};
var y = (c, i) switch
{
('L', _) => '#',
('#', true) => 'L',
('#', false) => 'M',
(var z, _) => z,
_ => ' ',
};Diagnostic Ids: IDE0072 (Populate switch); CS8510 (The pattern is unreachable. It has already been handled by a previous arm of the switch expression or it is impossible to match.)
Expected Behavior:
No diagnostic to be reported on the first switch expression, as it is complete.
Actual Behavior:
IDE0072 is reported on the switch, indicating the analyzer believes that there is a missing branch; however (var z, _) covers all remaining cases.
Metadata
Metadata
Assignees
Labels
Area-IDEFeature - IDE0072Populate switch expressionPopulate switch expressionhelp wantedThe issue is "up for grabs" - add a comment if you are interested in working on itThe issue is "up for grabs" - add a comment if you are interested in working on it