@@ -1006,7 +1006,9 @@ impl TypeChecker {
if element_types[0].is_closed() {
element_types[0].clone()
} else {
- self.fresh_type_variable()
+ let type_ = self.fresh_type_variable();
+ self.add_equal_constraint(&element_types[0], &type_).ok();
+ type_
}
};
@@ -703,6 +703,11 @@ fn lists() {
get_typecheck_error("[[1 a], [1 b]]"),
TypeCheckError::IncompatibleTypesInList(..)
));
+
+ assert!(matches!(
+ get_typecheck_error("fn f(x) = [[x], x]"),
+ TypeCheckError::ConstraintSolverError(..)
+ ));
#[test]