1
0
Fork 0
mirror of synced 2025-09-23 12:18:44 +00:00

fix type of repeat after inference

This commit is contained in:
schaeff 2021-04-26 18:58:01 +02:00
parent 6dbf98df7a
commit 3fa3f3978b
2 changed files with 9 additions and 2 deletions

View 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])

View file

@ -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),
}