1
0
Fork 0
mirror of synced 2025-09-23 20:28:36 +00:00

reduce spreads of inline arrays during semantic checking

This commit is contained in:
schaeff 2019-08-26 13:17:29 +02:00
parent 2c679a8cb7
commit 1eb51a4adc

View file

@ -657,18 +657,24 @@ impl<'ast> Checker<'ast> {
let checked_expression = self.check_expression(s.value.expression)?;
match checked_expression {
TypedExpression::FieldElementArray(e) => {
let size = e.size();
Ok((0..size)
.map(|i| {
FieldElementExpression::Select(
box e.clone(),
box FieldElementExpression::Number(T::from(i)),
)
.into()
})
.collect())
}
TypedExpression::FieldElementArray(e) => match e {
// if we're doing a spread over an inline array, we return the inside of the array: ...[x, y, z] == x, y, z
FieldElementArrayExpression::Value(_, v) => {
Ok(v.into_iter().map(|e| e.into()).collect())
}
e => {
let size = e.size();
Ok((0..size)
.map(|i| {
FieldElementExpression::Select(
box e.clone(),
box FieldElementExpression::Number(T::from(i)),
)
.into()
})
.collect())
}
},
e => Err(Error {
pos: Some(pos),