Assign correct types to struct-like enum variant constructors
Before, the type was just the enum type itself, which caused an assertion failure in iter_variant in trans::base. r=brson Closes #4229
This commit is contained in:
parent
cf768ce1f4
commit
499a58708f
3 changed files with 29 additions and 2 deletions
11
src/test/run-pass/enum-variants.rs
Normal file
11
src/test/run-pass/enum-variants.rs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
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 };
|
||||
// permuting the fields should work too
|
||||
let c = Cat { weight: 3.1, name: ~"Spreckles" };
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue