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

ICE with struct-like enum variants #4229

Closed
catamorphism opened this issue Dec 20, 2012 · 2 comments
Closed

ICE with struct-like enum variants #4229

catamorphism opened this issue Dec 20, 2012 · 2 comments
Labels
A-codegen Area: Code generation I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Milestone

Comments

@catamorphism
Copy link
Contributor

I'm not even sure if this should work, but it does pass typechecking.

enum Animal {
    Dog (~str, float),
    Cat { name: ~str, weight: float }
}

fn main() {
    let mut a: Animal = Dog(~"Cocoa", 37.2);
    a = Cat{ name: ~"Spotty", weight: 2.7 };
}

This yields an ICE in trans:

error: internal compiler error: iter_variant: not a function type

The message is from trans::base::iter_structural_ty.

@ghost ghost assigned catamorphism Dec 20, 2012
@catamorphism
Copy link
Contributor Author

It seems like typeck::collect::get_enum_variant_types assigns the wrong type to a struct variant constructor (the enum type itself, rather than an function mapping the struct fields to the enum type). Trying to fix it.

catamorphism added a commit to catamorphism/rust that referenced this issue Dec 20, 2012
Before, the type was just the enum type itself, which caused an
assertion failure in iter_variant in trans::base.

As per rust-lang#4229
@catamorphism
Copy link
Contributor Author

Fixed, see #4233

@catamorphism catamorphism removed their assignment Jun 16, 2014
RalfJung pushed a commit to RalfJung/rust that referenced this issue Mar 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

1 participant