Skip to content

Two fixes to NamedTuple pattern matching #22953

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

Merged
merged 3 commits into from
Apr 11, 2025
Merged

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Apr 9, 2025

  1. Fix translation for named patterns where the selector is a single-element named tuple. We used to take the whole tuple as result (which is correct for unnamed patterns) but for named patterns we have to select the field instead.
  2. Take account of named patterns in the refutability check.

 1. Fix translation for named patterns where the selector is a single-element
    named tuple. We used to take the whole tuple as result (which is correct
    for unnamed patterns) but for named patterns we have to select the field
    instead.
 2. Take account of named patterns in the refutability check.
@odersky odersky requested a review from sjrd April 9, 2025 13:53
@odersky
Copy link
Contributor Author

odersky commented Apr 9, 2025

Fixes #22900

@odersky odersky linked an issue Apr 9, 2025 that may be closed by this pull request
@odersky
Copy link
Contributor Author

odersky commented Apr 10, 2025

It would be nice if we could ship this in 3.7.0 RC3, since

  • it fixes a bug of the worst category (code generated that crashes at runtime), and
  • it is related to a new feature that ships in 3.7.

But only if it does not hold up the release.

Copy link
Member

Choose a reason for hiding this comment

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

Implementation looks good.

It seems the tests were intended to have check files (they println things rather than assert), but there are no checkfiles.

@odersky
Copy link
Contributor Author

odersky commented Apr 10, 2025

Now also fixes #22899

@sjrd sjrd enabled auto-merge April 10, 2025 12:41
@sjrd sjrd merged commit 98c84c3 into scala:main Apr 11, 2025
29 checks passed
@sjrd sjrd deleted the fix-22900 branch April 11, 2025 00:52
@tgodzik tgodzik added the backport:nominated If we agree to backport this PR, replace this tag with "backport:accepted", otherwise delete it. label Apr 14, 2025
WojciechMazur added a commit that referenced this pull request Apr 14, 2025
Backports #22953 to the 3.7.0-RC2.

PR submitted by the release tooling.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:nominated If we agree to backport this PR, replace this tag with "backport:accepted", otherwise delete it.
Projects
None yet
3 participants