1
0

Fix type check tests

This commit is contained in:
Jeff 2024-06-17 11:02:13 -04:00
parent 9e0c0b4db3
commit dbabf874b7

View File

@ -79,6 +79,48 @@ impl Type {
return Ok(());
}
}
(
Type::List {
length: left_length,
item_type: left_type,
},
Type::List {
length: right_length,
item_type: right_type,
},
) => {
if left_length != right_length || left_type != right_type {
return Err(TypeConflict {
actual: other.clone(),
expected: self.clone(),
});
}
return Ok(());
}
(
Type::ListOf(left_type),
Type::List {
item_type: right_type,
..
},
)
| (
Type::List {
item_type: right_type,
..
},
Type::ListOf(left_type),
) => {
if right_type.check(&left_type).is_err() {
return Err(TypeConflict {
actual: other.clone(),
expected: self.clone(),
});
} else {
return Ok(());
}
}
(
Type::Function {
type_parameters: left_type_parameters,
@ -103,6 +145,7 @@ impl Type {
});
}
}
for (left_parameter, right_parameter) in left_value_parameters
.iter()
.zip(right_value_parameters.iter())