-
Notifications
You must be signed in to change notification settings - Fork 155
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
Implement name resolution for the IfLet expression. #1241
Conversation
4bb5de6
to
a91b138
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks good to me, but waiting for @philberty's expert opinion. One way to test this would be to add a test case using an if let
construct with a pattern which depends on name resolution, something like:
mod a {
enum Foo {
Bar,
Baz(i32),
}
}
fn main() -> i32 {
let value = a::Foo::Baz(15);
if let a::Foo::Baz(value) = a {
return 0;
}
1
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good. What sort of test-case are you using at the moment?
@philberty still trying to compile the code from #1177
It fails with
I don't know if this error should be fixed by this PR or not. |
@antego I think this might be because you're not inserting a new definition? I'm not really sure as I've never worked on pattern resolution before. But the assertion is being triggered because the Sorry if this doesn't help :DD Trying to figure out something so you can progress! |
@CohenArthur appreciate the attempt but I still can't understand why While trying out different things I noticed that the part of the test code which causes the error is actually the line
The minimal test case that fails with the error above is:
looking into this |
This test case
fails with the error
Looks like the name resolution part is figured out and the type resolution is next? |
I guess the failing name resolution for enums should be addressed in another issue? |
@CohenArthur @philberty are you happy to merge this PR since the name resolution doesn't throw the error anymore? |
bors try |
@antego sorry this is my fault let me double-check the merge is ok first :) |
tryBuild succeeded: |
bors r+ |
Build succeeded: |
Addresses #1177.
Guidance from the ticket #1177:
I don't understand how to modify the block expression resolution so that it can handle the
IfLet
expression. For now, I copied the code from theMatchExpr
resolution. Not sure how to test it either and what is the desired expected result of the name resolution so I just hope that reviewers will spot the errors.I created this PR in order to get some guidance about how to proceed with it. Thanks!