Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ impl Function {
}
}
Instruction::ArrayGet { array, index, offset }
| Instruction::ArraySet { array, index, offset, .. } => {
| Instruction::ArraySet { array, index, offset, .. }
if context.dfg.runtime().is_acir() =>
{
let array_or_slice_type = context.dfg.type_of_value(*array);
let array_op_always_fails = match &array_or_slice_type {
Type::Slice(_) => false,
Expand Down Expand Up @@ -896,4 +898,23 @@ mod test {
}
");
}

#[test]
fn do_not_transform_failing_array_access_in_brillig() {
let src = "
brillig(inline) predicate_pure fn main f0 {
b0():
v0 = allocate -> &mut u8
store u8 0 at v0
v2 = make_array [u8 0, v0] : [(u8, &mut u8); 1]
v4 = array_get v2, index u32 2 -> u8
v6 = array_get v2, index u32 3 -> &mut u8
return v4
}
";

let ssa = Ssa::from_str(src).unwrap();
let ssa = ssa.remove_unreachable_instructions();
assert_normalized_ssa_equals(ssa, src);
}
}
Loading