-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Self-referential templated trait overflows the stack #15477
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Indeed, even a "corrected" version (in that I provided an argument for the type param in the trait in the bound) still overflows the stack: #![crate_type="lib"]
trait Chromosome<C: Chromosome<C>> {
fn random() -> C;
} (I just note this because while I agree that the original example was not valid, I believe the variant I have written is valid and should be accepted by the compiler. But we can wait for post 1.0 for it to be accepted. For 1.0 itself, I would be okay with rejecting this program; we should just do it properly.) Make sure that we test this variant too: #![crate_type="lib"]
trait X<C: Y<C>> {}
trait Y<C: X<C>> {} |
hmm, indeed, from reading #8762, I guess the consensus tends to be that this code should not be accepted, though for some reason I had thought that the variant I had written with proper instantaations was sound. Perhaps just not compatible with our monomorphizaton model, though I would have thought that for trait definitions this would still be fine. |
This still overflows the stack today. |
No longer reproducible. |
feat: Record import aliases in symbol index Fixes rust-lang/rust-analyzer#7938
Compiling the following:
Causes the following output:
The code was an unintentional typo, and probably isn't valid, but I think the compiler should handle this a lot better, as there's no indication of what the problem is, or where it lies. In large compilation units with complex templating etc., that could be a big roadblock.
The text was updated successfully, but these errors were encountered: