Skip to content

Commit

Permalink
fix: Ssa typing for assign_lvalue_index (noir-lang#4289)
Browse files Browse the repository at this point in the history
# Description

## Problem\*

Partial work towards noir-lang#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.
  • Loading branch information
sirasistant authored Feb 7, 2024
1 parent 4074bab commit 37f149c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions compiler/noirc_evaluator/src/ssa/ssa_gen/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 37f149c

Please sign in to comment.