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

Ignore new unreachable_switch_default warning. #2318

Merged
merged 1 commit into from
Aug 26, 2024

Conversation

stereotype441
Copy link
Contributor

The Dart analyzer will soon be changed so that if the default clause of a switch statement is determined to be unreachable by the exhaustiveness checker, a new warning of type
unreachable_switch_default will be issued. This parallels the behavior of the existing unreachable_switch_case warning, which is issued whenever a case clause of a switch statement is determined to be unreachable.

In the vast majority of cases, the most reasonable way to address the warning is to remove the unreachable default clause. However, in a few rare cases, the default clause must be kept, due to the fact that flow analysis is not as sophisticated as exhaustiveness checking (see dart-lang/language#2977 for details).

Two of these rare cases crop up in dart-sass. This change adds ignore comments to avoid a spurious warning, and adds a comment explaining why the default clause needs to be kept.

The Dart analyzer will soon be changed so that if the `default` clause
of a `switch` statement is determined to be unreachable by the
exhaustiveness checker, a new warning of type
`unreachable_switch_default` will be issued. This parallels the
behavior of the existing `unreachable_switch_case` warning, which is
issued whenever a `case` clause of a `switch` statement is determined
to be unreachable.

In the vast majority of cases, the most reasonable way to address the
warning is to remove the unreachable `default` clause. However, in a
few rare cases, the `default` clause must be kept, due to the fact
that flow analysis is not as sophisticated as exhaustiveness checking
(see dart-lang/language#2977 for details).

Two of these rare cases crop up in dart-sass. This change adds
`ignore` comments to avoid a spurious warning, and adds a comment
explaining why the `default` clause needs to be kept.
Copy link
Contributor

@nex3 nex3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the proactive mitigation!

@nex3 nex3 merged commit 9f82850 into sass:main Aug 26, 2024
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants