1
0

Fix assignment bug

This commit is contained in:
Jeff 2024-06-24 00:47:11 -04:00
parent 64ce3d56e4
commit 40172e3ffb
2 changed files with 15 additions and 3 deletions

View File

@ -45,6 +45,8 @@ impl Assignment {
impl AbstractNode for Assignment { impl AbstractNode for Assignment {
fn define_types(&self, context: &Context) -> Result<(), ValidationError> { fn define_types(&self, context: &Context) -> Result<(), ValidationError> {
self.statement.define_types(context)?;
let relevant_statement = self.statement.last_evaluated_statement(); let relevant_statement = self.statement.last_evaluated_statement();
let statement_type = if let Some(r#type) = relevant_statement.expected_type(context)? { let statement_type = if let Some(r#type) = relevant_statement.expected_type(context)? {
r#type r#type
@ -113,7 +115,7 @@ impl AbstractNode for Assignment {
r#type r#type
} else { } else {
return Err(ValidationError::CannotAssignToNone( return Err(ValidationError::CannotAssignToNone(
self.statement.position(), relevant_statement.position(),
)); ));
}; };

View File

@ -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)) = if let (Some(parameters), Some(arguments)) =
(function.value_parameters(), self.value_arguments) (function.value_parameters(), self.value_arguments)