From 2d2fc72ff96a829830b11a3d6911cb6bdd8224cd Mon Sep 17 00:00:00 2001 From: collin Date: Wed, 25 Nov 2020 17:22:12 -0500 Subject: [PATCH] fixes array spread declaration type bug --- type-inference/src/objects/frame.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/type-inference/src/objects/frame.rs b/type-inference/src/objects/frame.rs index 0daeba20dd..6a455e61de 100644 --- a/type-inference/src/objects/frame.rs +++ b/type-inference/src/objects/frame.rs @@ -310,7 +310,6 @@ impl Frame { if variables.names.len() == 1 { // Insert variable into symbol table let variable = variables.names[0].clone(); - self.insert_variable(variable.identifier.name, actual_type, span)?; } else { // Expect a tuple type. @@ -867,7 +866,7 @@ impl Frame { fn parse_array_access(&mut self, type_: Type, r_or_e: &RangeOrExpression, span: &Span) -> Result { // Check the type is an array. let element_type = match type_ { - Type::Array(type_) => type_, + Type::Array(type_) => *type_, type_ => return Err(FrameError::array_access(&type_, span)), }; @@ -890,6 +889,9 @@ impl Frame { self.assert_index(&type_, span); } + + // Return a new array type. + Ok(Type::Array(Box::new(element_type))) } RangeOrExpression::Expression(expression) => { // Parse the expression type. @@ -897,10 +899,11 @@ impl Frame { // Assert the type is an index. self.assert_index(&type_, span); + + // Return the element type. + Ok(element_type) } } - - Ok(*element_type) } ///