-
Notifications
You must be signed in to change notification settings - Fork 1.7k
document that no_duplicate_case_values
is a no-op in Dart 3.0+
#58863
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
Comments
If I understand the exhaustiveness proposal right, unreachable cases will be treated as errors so this lint should not fire and there should be nothing to do here. |
@munificent: is this right? |
The const String A = 'a';
String v = 'aa';
switch (v) {
case 'aa': // OK
case 'bb': // OK
case A + A: // LINT
case 'bb': // LINT
case A + 'b': // OK
default:
} The exhaustiveness spec talks about literal or constant matcher:
Anyhow, even if there is a difference, maybe we can claim its not interesting. |
Another thing to worry about with generalized pattern matching: Cases also get switch (e) {
case 1 when random.nextBool(): print("1/1");
case 1: print("1/2");
} which is a kind-of silly way to randomly select between two cases, but it's allowed. Safest aproach is probably to not apply this lint to any |
no_duplicate_case_values
works with switch-expressionsno_duplicate_case_values
does NOT lint SwitchPatternCase
s
As implemented, this lint will not fire on |
no_duplicate_case_values
does NOT lint SwitchPatternCase
sno_duplicate_case_values
is a no-op in Dart 3.0+
The corresponding lint is no-op in 3.0 https://github.com/dart-lang/linter/issues/3674 Bug: #49759 Change-Id: I24fd82240d8e94e763742c546ec2d4cf3c4df8cb Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306126 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
https://github.com/dart-lang/language/blob/master/working/0546-patterns/patterns-feature-specification.md#switch-expression
The text was updated successfully, but these errors were encountered: