fix type of repeat after inference
This commit is contained in:
parent
6dbf98df7a
commit
3fa3f3978b
2 changed files with 9 additions and 2 deletions
5
zokrates_cli/examples/arrays/multi_init.zok
Normal file
5
zokrates_cli/examples/arrays/multi_init.zok
Normal file
|
@ -0,0 +1,5 @@
|
|||
def identity<N>(field[N][N] t) -> field[N][N]:
|
||||
return t
|
||||
|
||||
def main() -> field[1][1]:
|
||||
return identity([[0]; 1])
|
|
@ -476,7 +476,7 @@ impl<'ast, T: Field> ArrayExpression<'ast, T> {
|
|||
}
|
||||
}
|
||||
|
||||
// precondition: `array` is only made of inline arrays unless it does not contain the Integer type
|
||||
// precondition: `array` is only made of inline arrays and repeat constructs unless it does not contain the Integer type
|
||||
pub fn try_from_int(
|
||||
array: Self,
|
||||
target_inner_ty: Type<'ast, T>,
|
||||
|
@ -518,8 +518,10 @@ impl<'ast, T: Field> ArrayExpression<'ast, T> {
|
|||
// try to convert the repeated element to the target type
|
||||
t => TypedExpression::align_to_type(e, t)
|
||||
.map(|e| {
|
||||
let ty = e.get_type().clone();
|
||||
|
||||
ArrayExpressionInner::Repeat(box e, box count)
|
||||
.annotate(target_inner_ty, array_ty.size)
|
||||
.annotate(ty, array_ty.size)
|
||||
})
|
||||
.map_err(|(e, _)| e),
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue