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

Pattern match rest as #6030

Merged
merged 12 commits into from
Nov 21, 2023
Merged

Pattern match rest as #6030

merged 12 commits into from
Nov 21, 2023

Conversation

bhansconnect
Copy link
Collaborator

@bhansconnect bhansconnect commented Nov 20, 2023

Still need to add some tests, but seems to be working!

Fixes #5187

Copy link
Member

@ayazhafiz ayazhafiz left a comment

Choose a reason for hiding this comment

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

LGTM besides a few comments

crates/compiler/mono/src/layout/semantic.rs Outdated Show resolved Hide resolved
element_layout: InLayout<'a>,
elements: &[Pattern<'a>],
opt_rest: &Option<(usize, Option<Symbol>)>,
Copy link
Member

Choose a reason for hiding this comment

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

Is this ever (usize, None)?

Copy link
Collaborator Author

@bhansconnect bhansconnect Nov 21, 2023

Choose a reason for hiding this comment

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

(usize, None) does happen higher up in the ast if we have a spread that doesn't capture (at least that is my assumption, didn't double check the code the code) (double checked, yeah, that happens and matter higher up the stack).

Originally I had it converting to Option<(usize, Symbol)> cause mono only cares about it if the symbol exists.

I removed it cause it felt unnecessary to have two checks. One to go to this other format and one in mono to decide if we should generate the the binding for rest. I can change it back to that if you want.

Copy link
Member

Choose a reason for hiding this comment

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

Ah gotcha. Makes sense. No need to change i think

crates/compiler/mono/src/ir/pattern.rs Show resolved Hide resolved
@bhansconnect bhansconnect merged commit 08ee6ed into main Nov 21, 2023
14 checks passed
@bhansconnect bhansconnect deleted the pattern-match-rest-as branch November 21, 2023 16:06
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.

Fix support for a rest variable in list pattern matching
2 participants