-
Notifications
You must be signed in to change notification settings - Fork 10.5k
More error checking for member type lookup #620
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
Conversation
Thanks! |
More error checking for member type lookup
@jtbandes Thanks for looking into this, but ideally you should investigate why the nested type is missing instead of hiding the issue. |
@jtbandes In particular, setting a type to ErrorType does not guarantee a diagnostic gets produced. ErrorType leaking out in the type checked AST will just crash later. |
@slavapestov Thanks for the feedback. What would be the course of action after figuring out why it's missing? If you look at the test cases that were crashing, there is some clearly invalid syntax that produces ErrorType (and usually the diagnostic is produced immediately when that happens), so it seemed to me that propagating the ErrorType was the right thing to do. Is there some way of handling errors like this without propagating? |
@jtbandes Propagating an ErrorType like in the other commit is fine. In this commit, you're returning an ErrorType when getNestedType() returns null. I don't think the that's supposed to happen because we should have already resolved the name by then, so we should figure out the root cause, but I might be wrong. Do you want to try reducing one of the crashing test cases further, then it might be obvious what's going on. |
OK, I can take a look later this evening. |
Looking at this test case,
It crashes trying to look up 'e'. If I remove the 'class B{' in the middle, it stops crashing and correctly diagnoses errors. The code is invalid anyway so there's not much point making this work too much, but its worth figuring out why it can't find 'e' when the class is in the middle. It might help you fix a more fundamental issue that will resolve more compiler crashers. |
@slavapestov It looks like this code doesn't traverse more than one level of parents, so adding the I don't know what the right course of action is — I'm not sure why it would ever be okay for |
@jtbandes I think the problem is that when we look up 'e', we're looking it up in the archetype for the inner protocol's 'Self', when it should be using the outer 'Self'. The reason this code assumes the archetype exists is that we should have already caught invalid type names by now. The name lookup code found the decl for the type 'e', but the archetype builder didn't create an archetype for it. However this sounds like it might be a tedious fix, and nested protocols is not something we ever want to support. So unless you see an opportunity to improve some existing logic here, I think we can go with the targeted fix for now. |
update swift-system to 1.1.0
Fixes a couple compiler_crashers and an IDE crasher.