fixing more pair issues
This commit is contained in:
parent
ebe415cfc9
commit
46c7cb797a
|
@ -342,6 +342,19 @@ impl TypedDataType {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn pair(fst_tipo: Rc<Type>, snd_tipo: Rc<Type>) -> Self {
|
||||
DataType {
|
||||
constructors: vec![],
|
||||
doc: None,
|
||||
location: Span::empty(),
|
||||
name: "Pair".to_string(),
|
||||
opaque: false,
|
||||
parameters: vec!["a".to_string(), "b".to_string()],
|
||||
public: true,
|
||||
typed_parameters: vec![fst_tipo, snd_tipo],
|
||||
}
|
||||
}
|
||||
|
||||
pub fn bool() -> Self {
|
||||
DataType {
|
||||
constructors: vec![
|
||||
|
|
|
@ -1328,6 +1328,17 @@ pub fn prelude_data_types(id_gen: &IdGenerator) -> IndexMap<DataTypeKey, TypedDa
|
|||
bool_data_type,
|
||||
);
|
||||
|
||||
let pair_data_type =
|
||||
TypedDataType::pair(generic_var(id_gen.next()), generic_var(id_gen.next()));
|
||||
|
||||
data_types.insert(
|
||||
DataTypeKey {
|
||||
module_name: "".to_string(),
|
||||
defined_type: "Pair".to_string(),
|
||||
},
|
||||
pair_data_type,
|
||||
);
|
||||
|
||||
// Option
|
||||
let option_data_type = TypedDataType::option(generic_var(id_gen.next()));
|
||||
data_types.insert(
|
||||
|
|
|
@ -649,6 +649,12 @@ impl<'a> CodeGenerator<'a> {
|
|||
} => {
|
||||
if check_replaceable_opaque_type(&record.tipo(), &self.data_types) {
|
||||
self.build(record, module_build_name, &[])
|
||||
} else if record.tipo().is_pair() {
|
||||
AirTree::pair_index(
|
||||
usize::try_from(*index).unwrap(),
|
||||
tipo.clone(),
|
||||
self.build(record, module_build_name, &[]),
|
||||
)
|
||||
} else {
|
||||
let function_name = format!("__access_index_{}", *index);
|
||||
|
||||
|
|
|
@ -653,6 +653,15 @@ pub fn lookup_data_type_by_tipo(
|
|||
None
|
||||
}
|
||||
}
|
||||
Type::Pair { .. } => {
|
||||
let data_type_key = DataTypeKey {
|
||||
module_name: "".to_string(),
|
||||
defined_type: "Pair".to_string(),
|
||||
};
|
||||
|
||||
data_types.get(&data_type_key).cloned().cloned()
|
||||
}
|
||||
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue