Skip to content

Commit

Permalink
Fix bug in iarray accumulators, and add lots of tests (#3020)
Browse files Browse the repository at this point in the history
* Fix iarray mistakes around accumulator

* Add local tests
  • Loading branch information
goldfirere authored Sep 10, 2024
1 parent fd9f792 commit bbdd463
Show file tree
Hide file tree
Showing 2 changed files with 529 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ocaml/otherlibs/stdlib_stable/iarray.ml
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,9 @@ let fold_left_map_local f acc input_array = exclave_
let len = length input_array in
if len = 0 then (acc, unsafe_of_local_array [||]) else begin
let rec go acc i = exclave_
let acc', elt = f acc (unsafe_get input_array i) in
let acc, elt = f acc (unsafe_get input_array i) in
if i = len - 1 then
acc', make_mutable_local len elt
acc, make_mutable_local len elt
else begin
let (_, output_array) as res = go acc (i+1) in
unsafe_set_local output_array i elt;
Expand Down Expand Up @@ -464,9 +464,9 @@ let fold_left_map_local_output f acc input_array = exclave_
let len = length input_array in
if len = 0 then (acc, unsafe_of_local_array [||]) else begin
let rec go acc i = exclave_
let acc', elt = f acc (unsafe_get input_array i) in
let acc, elt = f acc (unsafe_get input_array i) in
if i = len - 1 then
acc', make_mutable_local len elt
acc, make_mutable_local len elt
else begin
let (_, output_array) as res = go acc (i+1) in
unsafe_set_local output_array i elt;
Expand Down
Loading

0 comments on commit bbdd463

Please sign in to comment.