Skip to content
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

Discrepancy between IDE0072 and CS8510 #76080

Open
viceroypenguin opened this issue Nov 25, 2024 · 0 comments
Open

Discrepancy between IDE0072 and CS8510 #76080

viceroypenguin opened this issue Nov 25, 2024 · 0 comments
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@viceroypenguin
Copy link
Contributor

Version Used: Compiler version: '4.12.0-3.24523.4 (f3348c2)'. Language version: latest (13.0).

Steps to Reproduce:

  1. Enable EnforceCodeStyleInBuild
  2. Set AnalysisLevel to latest-all
  3. 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.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Language Design untriaged Issues and PRs which have not yet been triaged by a lead labels Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

2 participants