Skip to content

Commit 96dc616

Browse files
dbuenzlihhugo
authored andcommitted
Fix int32 values returned from bigarrays when wrapping Uint32Array objects.
1 parent 3b74e1a commit 96dc616

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

CHANGES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
## Features/Changes
33
* Misc: Bump magic number for ocaml 5.1
44
* Misc: changes to stay compatible with the next version of ppx_expect
5-
* Runtime: support conversion of Uint8ClampedArray typed arrays to bigarrays.
6-
5+
* Runtime: support conversion of Uint8ClampedArray typed arrays to bigarrays (#1472)
76

87
## Bug fixes
98
* Compiler: fix location for parsing errors when last token is a virtual semicolon
@@ -12,6 +11,7 @@
1211
* Compiler: consise body should allow any expression but object literals
1312
* Compiler: preserve [new] without arguments [new C] (vs [new C()]
1413
* Compiler: remove invalid rewriting of js (#1471, #1469)
14+
* Runtime: fix int32 values returned from bigarrays when wrapping Uint32Array objects (#1472)
1515

1616
# 5.2.0 (2023-04-28) - Lille
1717
## Features/Changes

runtime/bigarray.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,5 +895,10 @@ function caml_ba_kind_of_typed_array(ta){
895895
//Requires: caml_ba_create_unsafe
896896
function caml_ba_from_typed_array(ta){
897897
var kind = caml_ba_kind_of_typed_array(ta);
898+
var ta =
899+
/* Needed to avoid unsigned setters overflowing
900+
the range of OCaml [int32] values. */
901+
ta instanceof Uint32Array ?
902+
new Int32Array(ta.buffer ,ta.byteOffset, ta.length) : ta;
898903
return caml_ba_create_unsafe(kind, 0, [ta.length], ta);
899904
}

0 commit comments

Comments
 (0)