Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix panic when using repeated arrays which define variables (noi…
Browse files Browse the repository at this point in the history
jfecher authored and Sakapoi committed Oct 19, 2023

Verified

This commit was signed with the committer’s verified signature.
norrland Andreas Eriksson
1 parent 3ce5030 commit 62b51b3
Showing 2 changed files with 2 additions and 2 deletions.
3 changes: 1 addition & 2 deletions compiler/noirc_frontend/src/monomorphization/mod.rs
Original file line number Diff line number Diff line change
@@ -412,12 +412,11 @@ impl<'interner> Monomorphizer<'interner> {
) -> ast::Expression {
let typ = self.convert_type(&self.interner.id_type(array));

let contents = self.expr(repeated_element);
let length = length
.evaluate_to_u64()
.expect("Length of array is unknown when evaluating numeric generic");

let contents = vec![contents; length as usize];
let contents = vecmap(0..length, |_| self.expr(repeated_element));
ast::Expression::Literal(ast::Literal::Array(ast::ArrayLiteral { contents, typ }))
}

Original file line number Diff line number Diff line change
@@ -7,4 +7,5 @@ fn main() {
let _ = 42;

let Foo { a: _ } = Foo { a: 42 };
let _regression_2786 = [Foo { a: 1 }; 8];
}

0 comments on commit 62b51b3

Please sign in to comment.