Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Improve diagnostic for refutable extractors in pattern bindings #14988

Merged
merged 1 commit into from
May 10, 2022

Conversation

griggt
Copy link
Contributor

@griggt griggt commented Apr 20, 2022

Avoids nonsensical messages such as:

  pattern's type Int is more specialized than the right hand side expression's type Int

when the underlying cause is that the extractor is refutable.

Extracted from #14294

Copy link
Member

@bishabosha bishabosha left a comment

Choose a reason for hiding this comment

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

This is a great improvement, I would like it more if the error message could remind the user that means either potential match failure for val definitions, or filtered entries in the for comprehension

@griggt griggt force-pushed the refutable-extractor-diagnostics branch from 6e62644 to cb0457a Compare May 9, 2022 20:55
@griggt griggt requested a review from bishabosha May 9, 2022 20:55
else "will result in a filtering for expression (using `withFilter`)"
val usage = reason match
case NonConforming => "the narrowing"
case RefutableExtractor => "this usage"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suddenly, I want to write two novels about the sinister underworld, one called "The Narrowing" and the other called "This Usage".

Copy link
Member

@bishabosha bishabosha left a comment

Choose a reason for hiding this comment

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

very nice

@bishabosha bishabosha added this to the 3.2.0-RC1 milestone May 9, 2022
Avoids nonsensical messages such as:

  pattern's type Int is more specialized than the right hand side expression's type Int

when the underlying cause is that the extractor is refutable.
@griggt griggt force-pushed the refutable-extractor-diagnostics branch from cb0457a to 3ddbf8e Compare May 9, 2022 23:41
@griggt griggt enabled auto-merge May 9, 2022 23:42
@griggt griggt merged commit 96ac286 into scala:main May 10, 2022
@griggt griggt deleted the refutable-extractor-diagnostics branch May 10, 2022 00:57
@Kordyjan Kordyjan modified the milestones: 3.2.0-RC1, 3.2.0 Aug 1, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants