Merge pull request #987 from Zokrates/fix-empty-spread-propagation
Fix empty spread propagation
This commit is contained in:
commit
b18ea01525
3 changed files with 22 additions and 1 deletions
1
changelogs/unreleased/987-schaeff
Normal file
1
changelogs/unreleased/987-schaeff
Normal file
|
@ -0,0 +1 @@
|
|||
Fix incorrect propagation of spreads
|
16
zokrates_cli/examples/empty_spread_propagation.zok
Normal file
16
zokrates_cli/examples/empty_spread_propagation.zok
Normal 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
|
|
@ -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(),
|
||||
|
|
Loading…
Reference in a new issue