From 49dfdc4e10e35a25f984dcb057e596ce23ae175e Mon Sep 17 00:00:00 2001 From: Jeff Date: Mon, 24 Jun 2024 02:26:19 -0400 Subject: [PATCH] Pass all tests --- dust-lang/src/abstract_tree/assignment.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/dust-lang/src/abstract_tree/assignment.rs b/dust-lang/src/abstract_tree/assignment.rs index c245a24..abc115b 100644 --- a/dust-lang/src/abstract_tree/assignment.rs +++ b/dust-lang/src/abstract_tree/assignment.rs @@ -96,7 +96,25 @@ impl AbstractNode for Assignment { } fn validate(&self, context: &Context, manage_memory: bool) -> Result<(), ValidationError> { - self.statement.validate(context, manage_memory) + self.statement.validate(context, manage_memory)?; + + let statement_type = self.statement.expected_type(context)?; + + if let (Some(expected_type_constructor), Some(actual_type)) = + (&self.constructor, statement_type) + { + let expected_type = expected_type_constructor.construct(context)?; + + expected_type + .check(&actual_type) + .map_err(|conflict| ValidationError::TypeCheck { + conflict, + actual_position: self.statement.last_evaluated_statement().position(), + expected_position: Some(expected_type_constructor.position()), + })?; + } + + Ok(()) } fn evaluate(