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

Fix: Perform scope discovery on match cases too #639

Merged
merged 1 commit into from
Dec 22, 2022
Merged

Conversation

kontheocharis
Copy link
Collaborator

The scope discovery and symbol resolution stages did not handle match cases before. This PR implements this. Match cases are similar to declarations in that bindings inside the pattern are added to the child scope. Consequently, match cases create their own scopes.

Closes #637.

@kontheocharis kontheocharis added the type-system Issues related with typechecking sub-system. label Dec 20, 2022
@kontheocharis kontheocharis self-assigned this Dec 20, 2022
@feds01
Copy link
Contributor

feds01 commented Dec 21, 2022

rebase?

Copy link
Contributor

@feds01 feds01 left a comment

Choose a reason for hiding this comment

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

LGTM, I don't mind if the suggestion is implemented or not.

Comment on lines +67 to +70
if let Some(name) = &spread.name {
if let Some(member_id) =
self.ast_info().stack_members().get_data_by_node(name.ast_ref().id())
{
Copy link
Contributor

Choose a reason for hiding this comment

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

could use a let_chain here:

Suggested change
if let Some(name) = &spread.name {
if let Some(member_id) =
self.ast_info().stack_members().get_data_by_node(name.ast_ref().id())
{
if let Some(name) = &spread.name && let Some(member_id) =
self.ast_info().stack_members().get_data_by_node(name.ast_ref().id())
{

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't like let chains cause they are not yet supported by rustfmt rust-lang/rustfmt#5203. So I'll just keep it like this for now..

@kontheocharis kontheocharis merged commit d748cf5 into main Dec 22, 2022
@kontheocharis kontheocharis deleted the fix-637 branch December 22, 2022 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-system Issues related with typechecking sub-system.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add bindings from matches to the context
2 participants