Skip to content

Commit

Permalink
Merge pull request #458 from AleoHQ/fix/array-type-inference
Browse files Browse the repository at this point in the history
fixes array spread declaration type bug
  • Loading branch information
howardwu authored Dec 1, 2020
2 parents 62e651a + 2d2fc72 commit ced0246
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions type-inference/src/objects/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -867,7 +866,7 @@ impl Frame {
fn parse_array_access(&mut self, type_: Type, r_or_e: &RangeOrExpression, span: &Span) -> Result<Type, FrameError> {
// 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)),
};

Expand All @@ -890,17 +889,21 @@ 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.
let type_ = self.parse_expression(expression)?;

// Assert the type is an index.
self.assert_index(&type_, span);

// Return the element type.
Ok(element_type)
}
}

Ok(*element_type)
}

///
Expand Down

0 comments on commit ced0246

Please sign in to comment.