- Notifications
You must be signed in to change notification settings - Fork471
Add support for ArrayBuffer and typed arrays to @unboxed#7788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
pkg-pr-newbot commentedAug 22, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
rescript@rescript/darwin-arm64@rescript/darwin-x64@rescript/linux-arm64@rescript/linux-x64@rescript/win32-x64commit: |
| |Someinstance_type ->Some (InstanceType instance_type)) | ||
| |{desc =Ttuple_} ->Some (InstanceTypeArray) | ||
| |_ ->None | ||
| (* First check the original (unexpanded) type for typed arrays and other instance types*) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The stdlib usest = Stdlib_TypedArray.t<int> andt = Stdlib_TypedArray.t<float> for typed arrays, so we can't differentiate them by their expanded types.
| @@ -1,5 +1,3 @@ | |||
| moduleArray=Ocaml_Array | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I removed this line and replacedarr[0] witharr->Array.getUnsafe(0) in the test to make compiling with./cli/bsc.js tests/tests/src/UntaggedVariants.res easier (bsc would complain about unknown dependencyOcaml_Array otherwise)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Can we have a summary of how these new types compare to other types in terms of runtime representation?
Are they all objects and are all instance of cases mutually exclusive (with each other and with existing types).
Just double checking where this extension sits wrt what's already there.
mediremi commentedAug 23, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
constbuffer=newArrayBuffer(8)constview=newInt32Array(buffer)console.log(typeofbuffer)// 'object'console.log(typeofview)// 'object' They can be differentiated with constbuffer=newArrayBuffer(8)constview=newInt32Array(buffer)console.log(bufferinstanceofArrayBuffer)// trueconsole.log(bufferinstanceofArray)// falseconsole.log(Array.isArray(buffer))// falseconsole.log(bufferinstanceofDataView)// falseconsole.log(viewinstanceofInt32Array)// trueconsole.log(viewinstanceofArray)// falseconsole.log(Array.isArray(view))// falseconsole.log(viewinstanceofArrayBuffer)// falseconsole.log(viewinstanceofDataView)// false |
fe531a2 intorescript-lang:masterUh oh!
There was an error while loading.Please reload this page.
@mediremi Could you add a CHANGELOG entry for this PR? |
Uh oh!
There was an error while loading.Please reload this page.
Closes#6757
While adding support for
ArrayBuffer.twas simple, supporting typed arrays (e.g.Int8Array) required changingAst_untagged_variants.get_block_type_from_typso it first looks at the unexpanded types (e.g.Int8Array) rather than just the fully expanded version (e.g.Stdlib_TypedArray.t).