Skip to content

Conversation

zielinsky
Copy link
Member

@zielinsky zielinsky commented Aug 24, 2025

We want to allow decomposition only on the right-hand side of a pattern if the type is not a type parameter, a type parameter reference, or a deferred type reference. This is because decomposition on the right-hand side of a pattern can lead to false positive warnings.

Fixes #20395
Fixes #20225

@zielinsky zielinsky changed the title Fix unreachable case warning (E121) Fix unreachable case warning Aug 24, 2025
@zielinsky zielinsky changed the title Fix unreachable case warning Fix false unreachable case warning Aug 24, 2025
@zielinsky zielinsky marked this pull request as ready for review August 26, 2025 10:14
@Gedochao Gedochao requested a review from hamzaremmal August 26, 2025 10:14
Copy link
Member

Choose a reason for hiding this comment

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

This should be moved to tests/pos.

Copy link
Contributor

@som-snytt som-snytt Sep 3, 2025

Choose a reason for hiding this comment

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

I think a test that no warnings are produced should be in tests/warn with -Werror to make plain that zero warnings are expected. That reserves pos for "successful compilation" (and avoids forgetting to add -Werror there). (I wish scala2 had warn tests to avoid pitfalls.) (I.e., tests/warn is not just for warnings behind -W flags, if that was the thinking, or only for tests that produce non-zero number of warnings.)

Copy link
Member

Choose a reason for hiding this comment

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

This test too should be moved to tests/pos

@hamzaremmal hamzaremmal assigned zielinsky and unassigned hamzaremmal Sep 3, 2025
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.

Wrong unreachable code reported for inline def pattern match Unreachable case warning (E121) in inline generic function
4 participants