-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
typeck hang with recursive type #2063
Comments
probably my fault. |
Not at all what I expected it to be. Rather, a loop in autoderef. I will fix the loop but I suppose it might also make sense to reject this type as uninstanitable---there should be some enum variant that does not require an instance of the enum itself. But I am not sure this is worth checking in general: after all, the user could never successfully construct an instance of that type, and to check it in general requires expanding and traversing enums and so forth. |
I think rejecting the type makes more sense. If we reject the type immediately, we won't need to change the autoderef loop, right? |
That's the idea. I independently came to the same conclusion. In particular, there are multiple autoderef loops (which ought to be consolidated more, but still) and I don't like the idea of this same kind of bug creeping up in another of them. |
Also, it's just a nicer error message. |
Unfortunately, we still need the loop check in the autoderef loop for typeck, because the actual checking that the enum is instantiable and the checking of the fn body occur in the same pass over the AST. We could change it to have three passes (one to compute types and generate info, one to check for instantiability, and one to check fn bodies and so forth) but that seems annoying. |
Could the pass bail out early after encountering an uninstantiable type? |
@jruderman No, the problem is that the autoderef loop could occur before we get around to checking whether the type is instantiable. As I said, I could restructure the pass to make sure we check all types for instantiability (and possibly other properties) before we delve into function bodies and expressions, but otherwise I think we still need to be careful when autoderef'ing. Such a restructuring might be a good idea though. |
Fixed in 23f92ea |
Should this be closed, then? |
Yes. |
The issue-2063.rs test has been |
That test case emits an error before hanging: One easy way to fix this would be to make that error emission site do a Nominating well-covered. |
It might be. The idea of this error was that code in typeck had to worry about this kind of infinite loop case, but not other code. But maybe it's too much trouble even within typeck. |
accepted for production-ready milestone |
High, but not 1.0 |
Fixing this bug should also fix this code: enum A {
A(B)
}
enum B {
B1, B2(B)
}
fn main() {} |
Not sure under what circumstances issue-2063.rs was originally The recursive-enum stack overflow issue pointed referenced by @alexcrichton is described in #3008, and addressed in pull request #11839. I don't think it's related to this. |
This seems to be fixed, closing. |
This hangs the compiler in typeck:
The text was updated successfully, but these errors were encountered: