diff --git a/dust-lang/src/abstract_tree/assignment.rs b/dust-lang/src/abstract_tree/assignment.rs index ba228c9..3c122a4 100644 --- a/dust-lang/src/abstract_tree/assignment.rs +++ b/dust-lang/src/abstract_tree/assignment.rs @@ -45,6 +45,8 @@ impl Assignment { impl AbstractNode for Assignment { fn define_types(&self, context: &Context) -> Result<(), ValidationError> { + self.statement.define_types(context)?; + let relevant_statement = self.statement.last_evaluated_statement(); let statement_type = if let Some(r#type) = relevant_statement.expected_type(context)? { r#type @@ -113,7 +115,7 @@ impl AbstractNode for Assignment { r#type } else { return Err(ValidationError::CannotAssignToNone( - self.statement.position(), + relevant_statement.position(), )); }; diff --git a/dust-lang/src/abstract_tree/function_call.rs b/dust-lang/src/abstract_tree/function_call.rs index 4e84afe..362fcd1 100644 --- a/dust-lang/src/abstract_tree/function_call.rs +++ b/dust-lang/src/abstract_tree/function_call.rs @@ -116,9 +116,19 @@ impl AbstractNode for FunctionCall { )); }; - function.populate_context_template()?; + let function_context = Context::new(None); - let function_context = function.context_template().create_child(); + if let Some(type_parameters) = function.type_parameters() { + for identifier in type_parameters { + function_context.set_type( + identifier.clone(), + Type::Generic { + identifier: identifier.clone(), + concrete_type: None, + }, + )?; + } + } if let (Some(parameters), Some(arguments)) = (function.value_parameters(), self.value_arguments)