summaryrefslogtreecommitdiff
path: root/stdlib/array.ml
diff options
context:
space:
mode:
authorthierry-martinez <thierry.martinez@inria.fr>2018-07-11 19:08:04 +0200
committerXavier Leroy <xavierleroy@users.noreply.github.com>2018-07-11 19:08:03 +0200
commit220063adff92beca4eefd00330fa9b39659ef3e7 (patch)
tree05fcd642196603f97ef019f33106081f3f10bd83 /stdlib/array.ml
parent309c8d4d8beb393a33e75136f783ff4ac98f24bc (diff)
downloadocaml-220063adff92beca4eefd00330fa9b39659ef3e7.tar.gz
Fix Array.of_seq (#1897)
Reported at https://caml.inria.fr/mantis/view.php?id=7820 Array.of_seq applies a circular permutation of one cell to the right on the sequence. With OCaml 4.07.0 and trunk, we have - : int array = [|3; 1; 2|] In stdlib/array.ml, line 337 (last line of of_rev_list), we have fill (len-1) tl whereas it should be fill (len-2) tl since hd, which should be assigned to the cell (len - 1), is skipped.
Diffstat (limited to 'stdlib/array.ml')
-rw-r--r--stdlib/array.ml2
1 files changed, 1 insertions, 1 deletions
diff --git a/stdlib/array.ml b/stdlib/array.ml
index d29a04faab..a693f4a72f 100644
--- a/stdlib/array.ml
+++ b/stdlib/array.ml
@@ -334,7 +334,7 @@ let of_rev_list = function
[] -> a
| hd::tl -> unsafe_set a i hd; fill (i-1) tl
in
- fill (len-1) tl
+ fill (len-2) tl
let of_seq i =
let l = Seq.fold_left (fun acc x -> x::acc) [] i in