fix: fieldsexpose getting wrong generic id and not replacing type

This commit is contained in:
Kasey White 2022-12-17 06:10:39 -05:00 committed by Lucas
parent 47fae21af7
commit 5b908aaeb7
2 changed files with 11 additions and 12 deletions

View File

@ -1020,7 +1020,6 @@ pub fn monomorphize(
needs_variant = false; needs_variant = false;
} }
} }
Air::BinOp { Air::BinOp {
scope, scope,
name, name,
@ -1153,8 +1152,8 @@ pub fn monomorphize(
let mut tipo = tipo.clone(); let mut tipo = tipo.clone();
find_generics_to_replace(&mut tipo, &generic_types); find_generics_to_replace(&mut tipo, &generic_types);
needs_variant = false; needs_variant = false;
new_indices.push((ind, name, tipo));
} }
new_indices.push((ind, name, tipo));
} }
new_air[index] = Air::FieldsExpose { new_air[index] = Air::FieldsExpose {
scope, scope,

View File

@ -922,9 +922,9 @@ impl<'a> CodeGenerator<'a> {
let mut type_map: HashMap<String, Arc<Type>> = HashMap::new(); let mut type_map: HashMap<String, Arc<Type>> = HashMap::new();
for arg in &constructor_type.arguments { for (index, arg) in tipo.arg_types().unwrap().iter().enumerate() {
let label = arg.label.clone().unwrap(); let label = constructor_type.arguments[index].label.clone().unwrap();
let field_type = arg.tipo.clone(); let field_type = arg.clone();
type_map.insert(label, field_type); type_map.insert(label, field_type);
} }
@ -1014,8 +1014,8 @@ impl<'a> CodeGenerator<'a> {
} else { } else {
let mut type_map: HashMap<usize, Arc<Type>> = HashMap::new(); let mut type_map: HashMap<usize, Arc<Type>> = HashMap::new();
for (index, arg) in constructor_type.arguments.iter().enumerate() { for (index, arg) in tipo.arg_types().unwrap().iter().enumerate() {
let field_type = arg.tipo.clone(); let field_type = arg.clone();
type_map.insert(index, field_type); type_map.insert(index, field_type);
} }
@ -1265,9 +1265,9 @@ impl<'a> CodeGenerator<'a> {
let mut type_map: HashMap<String, Arc<Type>> = HashMap::new(); let mut type_map: HashMap<String, Arc<Type>> = HashMap::new();
for arg in &constructor_type.arguments { for (index, arg) in tipo.arg_types().unwrap().iter().enumerate() {
let label = arg.label.clone().unwrap(); let label = constructor_type.arguments[index].label.clone().unwrap();
let field_type = arg.tipo.clone(); let field_type = arg.clone();
type_map.insert(label, field_type); type_map.insert(label, field_type);
} }
@ -1333,8 +1333,8 @@ impl<'a> CodeGenerator<'a> {
} else { } else {
let mut type_map: HashMap<usize, Arc<Type>> = HashMap::new(); let mut type_map: HashMap<usize, Arc<Type>> = HashMap::new();
for (index, arg) in constructor_type.arguments.iter().enumerate() { for (index, arg) in tipo.arg_types().unwrap().iter().enumerate() {
let field_type = arg.tipo.clone(); let field_type = arg.clone();
type_map.insert(index, field_type); type_map.insert(index, field_type);
} }