Skip to content

Commit

Permalink
Merge 7c6a024 into 5598059
Browse files Browse the repository at this point in the history
  • Loading branch information
sirasistant authored Sep 21, 2024
2 parents 5598059 + 7c6a024 commit dd27c23
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions compiler/noirc_evaluator/src/ssa/opt/die.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,17 @@ impl Context {
self.used_values.insert(value_id);
}
Value::Array { array, .. } => {
self.used_values.insert(value_id);
for elem in array {
self.mark_used_instruction_results(dfg, *elem);
}
}
Value::Param { .. } => {
self.used_values.insert(value_id);
}
Value::NumericConstant { .. } => {
self.used_values.insert(value_id);
}
_ => {
// Does not comprise of any instruction results
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "brillig_constant_reference_regression"
type = "bin"
authors = [""]

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sorted_index = ["1", "0"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
unconstrained fn main(sorted_index: [u32; 2]) {
let original = [
55,
11
];

let mut sorted = original; // Stores the constant "original" into the sorted reference

for i in 0..2 {
let index = sorted_index[i];
let value = original[index];
sorted[i] = value; // On first iteration, we should not mutate the original constant array, RC should be > 1
}

assert_eq(sorted[1], 55);
}

0 comments on commit dd27c23

Please sign in to comment.