Skip to content

Fix: Perform scope discovery on match cases too#639

Merged
kontheocharis merged 1 commit intomainfrom
fix-637
Dec 22, 2022
Merged

Fix: Perform scope discovery on match cases too#639
kontheocharis merged 1 commit intomainfrom
fix-637

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 requested a review from feds01 December 20, 2022 22:27
@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

Comments