From 37f149c68e195cf29f81bef4616739cda65f8da7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Rodr=C3=ADguez?= Date: Wed, 7 Feb 2024 11:22:34 +0100 Subject: [PATCH] fix: Ssa typing for assign_lvalue_index (#4289) # Description ## Problem\* Partial work towards https://github.com/noir-lang/noir/issues/4275 ## Summary\* Also use the array index type (u64) for assign_lvalue_index. ## Additional Context ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[Exceptional Case]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings. --- compiler/noirc_evaluator/src/ssa/ssa_gen/context.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/noirc_evaluator/src/ssa/ssa_gen/context.rs b/compiler/noirc_evaluator/src/ssa/ssa_gen/context.rs index e23a1dc3235..284bc9f41f5 100644 --- a/compiler/noirc_evaluator/src/ssa/ssa_gen/context.rs +++ b/compiler/noirc_evaluator/src/ssa/ssa_gen/context.rs @@ -994,12 +994,14 @@ impl<'a> FunctionContext<'a> { index: ValueId, location: Location, ) -> ValueId { - let element_size = self.builder.field_constant(self.element_size(array)); + let index = self.make_array_index(index); + let element_size = + self.builder.numeric_constant(self.element_size(array), Type::unsigned(64)); // The actual base index is the user's index * the array element type's size let mut index = self.builder.set_location(location).insert_binary(index, BinaryOp::Mul, element_size); - let one = self.builder.field_constant(FieldElement::one()); + let one = self.builder.numeric_constant(FieldElement::one(), Type::unsigned(64)); new_value.for_each(|value| { let value = value.eval(self);