From dbabf874b7f7a720ecf15a6d9ad6c36abb878036 Mon Sep 17 00:00:00 2001 From: Jeff Date: Mon, 17 Jun 2024 11:02:13 -0400 Subject: [PATCH] Fix type check tests --- dust-lang/src/abstract_tree/type.rs | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/dust-lang/src/abstract_tree/type.rs b/dust-lang/src/abstract_tree/type.rs index 03c8ebd..e9dd18c 100644 --- a/dust-lang/src/abstract_tree/type.rs +++ b/dust-lang/src/abstract_tree/type.rs @@ -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())