1
0
Fork 0
mirror of synced 2025-09-24 04:40:05 +00:00

Merge pull request #987 from Zokrates/fix-empty-spread-propagation

Fix empty spread propagation
This commit is contained in:
Thibaut Schaeffer 2021-09-01 00:08:04 +02:00 committed by GitHub
commit b18ea01525
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 1 deletions

View file

@ -0,0 +1 @@
Fix incorrect propagation of spreads

View file

@ -0,0 +1,16 @@
def func<N>() -> bool:
for u32 i in 0..N do
endfor
u64[N] y = [...[0; N-1], 1] // the rhs should *not* be reduced to [1] because the spread is not empty
u64 q = 0
for u32 i in 0..N do
q = y[i]
endfor
return true
def main():
assert(func::<2>())
return

View file

@ -1078,7 +1078,11 @@ impl<'ast, 'a, T: Field> ResultFolder<'ast, T> for Propagator<'ast, 'a, T> {
})
// ignore spreads over empty arrays
.filter_map(|e| match e {
TypedExpressionOrSpread::Spread(s) if s.array.size() == 0 => None,
TypedExpressionOrSpread::Spread(s)
if s.array.size() == UExpression::from(0u32) =>
{
None
}
e => Some(e),
})
.collect(),