Skip to content
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

(Mutual) recursive type aliases cause ICE #3165

Open
1 task
tamaroning opened this issue Sep 16, 2024 · 2 comments
Open
1 task

(Mutual) recursive type aliases cause ICE #3165

tamaroning opened this issue Sep 16, 2024 · 2 comments

Comments

@tamaroning
Copy link
Contributor

tamaroning commented Sep 16, 2024

Summary

might be related to #1178 and #2757
But the name resolver is the cause

Reproducer

I tried this code:

type C = crate::C;

type A = crate::B;
type B = crate::A;

Does the code make use of any (1.49) nightly feature ?

  • Nightly

Godbolt link

https://godbolt.org/z/dP6vb8Yf3

Actual behavior

The current behavior is...

crab1: internal compiler error: Segmentation fault
0x27a7a8c internal_error(char const*, ...)
	???:0
0xde47f4 Rust::TyTy::BaseType::get_kind() const
	???:0
0xe2fe91 Rust::Resolver::TypeCheckType::visit(Rust::HIR::TypePath&)
	???:0
0xe2dea5 Rust::Resolver::TypeCheckType::Resolve(Rust::HIR::Type*)
	???:0
0xe1f2df Rust::Resolver::TypeCheckItem::visit(Rust::HIR::TypeAlias&)
	???:0
0xe1f950 Rust::Resolver::TypeCheckItem::Resolve(Rust::HIR::Item&)
	???:0
0xe74553 Rust::Resolver::query_type(unsigned int, Rust::TyTy::BaseType**)
	???:0
0xe2ef48 Rust::Resolver::TypeCheckType::resolve_root_path(Rust::HIR::TypePath&, unsigned long*, unsigned int*)
	???:0
0xe2fe86 Rust::Resolver::TypeCheckType::visit(Rust::HIR::TypePath&)
	???:0
0xe2dea5 Rust::Resolver::TypeCheckType::Resolve(Rust::HIR::Type*)
	???:0
0xe1f2df Rust::Resolver::TypeCheckItem::visit(Rust::HIR::TypeAlias&)
	???:0
0xe1f950 Rust::Resolver::TypeCheckItem::Resolve(Rust::HIR::Item&)
	???:0
0xddbb9b Rust::Resolver::TypeResolution::Resolve(Rust::HIR::Crate&)
	???:0
0xc35907 Rust::Session::compile_crate(char const*)
	???:0
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1

Expected behavior

I expected to see...

error[E0391]: cycle detected when computing type of `C`
 --> <source>:1:10
  |
1 | type C = crate::C;
  |          ^^^^^^^^
  |
  = note: ...which again requires computing type of `C`, completing the cycle
note: cycle used when collecting item types in top-level module
 --> <source>:1:1
  |
1 | / type C = crate::C;
2 | |
3 | | type A = crate::B;
4 | | type B = crate::A;
  | |__________________^

error[E0391]: cycle detected when computing type of `A`
 --> <source>:3:10
  |
3 | type A = crate::B;
  |          ^^^^^^^^
  |
note: ...which requires computing type of `B`...
 --> <source>:4:10
  |
4 | type B = crate::A;
  |          ^^^^^^^^
  = note: ...which again requires computing type of `A`, completing the cycle
note: cycle used when collecting item types in top-level module
 --> <source>:1:1
  |
1 | / type C = crate::C;
2 | |
3 | | type A = crate::B;
4 | | type B = crate::A;
  | |__________________^

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0391`.
Compiler returned: 1

GCC Version

master

@philberty
Copy link
Member

I think this is something that needs fixed during type checking there are a few variations of this issue now

@philberty
Copy link
Member

We actually don't have any handling for recursive types because its complicated for both typechecking and code generation. I am holding off fixing it until i am more confident after we fix more bugs in generics and method resolution first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants