Add S52 lint rule for detecting duplicate cases in switch statements - #1322
Draft
BrettMayson with Copilot wants to merge 2 commits into
Draft
Add S52 lint rule for detecting duplicate cases in switch statements#1322BrettMayson with Copilot wants to merge 2 commits into
BrettMayson with Copilot wants to merge 2 commits into
Conversation
Co-authored-by: BrettMayson <3946739+BrettMayson@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add lint detection for duplicated cases in switch statements
Add S52 lint rule for detecting duplicate cases in switch statements
Aug 30, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files
🚀 New features to boost your workflow:
|
PabstMirror
reviewed
Aug 30, 2026
| } | ||
|
|
||
| fn include(&self) -> bool { | ||
| true |
PabstMirror
reviewed
Aug 30, 2026
| switch (_value) do { | ||
| case 1: { "one" }; | ||
| case 2: { "two" }; | ||
| case default { "other" }; |
Collaborator
There was a problem hiding this comment.
invalid syntax
Suggested change
| case default { "other" }; | |
| default { "other" }; |
PabstMirror
reviewed
Aug 30, 2026
| } | ||
| } | ||
|
|
||
| // Pattern 2: case VALUE do EXPR (where case is binary) |
Collaborator
There was a problem hiding this comment.
case x do {} isn't a thing
I guess technically case returns "Switch Type"
but it just doesn't work
PabstMirror
reviewed
Aug 30, 2026
| // Try to find case VALUE: EXPR pattern | ||
| // This is structured as: case VALUE : EXPR | ||
| // Where "case" is typically a unary command or binary command | ||
| // and ":" is an Associate operator |
Collaborator
There was a problem hiding this comment.
should also think about single case expressions
switch test do {
case 1;
case 2: { "X" };
case 1: { "Y"};
};
This was referenced Aug 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement a new lint rule (S52) to detect duplicate case values within switch statements, addressing the request to identify unreachable duplicate case branches.
Changes
case VALUE : EXPRandcase VALUE do EXPR)Example
The lint now correctly identifies this common issue:
All existing lint tests pass with no regressions.