-
Notifications
You must be signed in to change notification settings - Fork 105
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"TypeError: out-of-bound numeric index" on typed arrays in strict mode #645
Comments
I'll dive in the spec, but aligning with other engines would likely be good here. |
saghul
added a commit
that referenced
this issue
Nov 5, 2024
Relevant spec section: https://tc39.es/ecma262/multipage/ordinary-and-exotic-objects-behaviours.html#sec-typedarraysetelement It should only throw if the backing buffer is detached, which test262 tests for. Fixes: #645
PR: #647 It's interesting test262 doesn't seem to cover this. It does, however, cover the case of setting a numeric property on a TA where the backing array buffer is detached. |
This is fixed as of #646 |
Sorry, my bad, strict mode! |
saghul
added a commit
that referenced
this issue
Nov 7, 2024
Relevant spec section: https://tc39.es/ecma262/multipage/ordinary-and-exotic-objects-behaviours.html#sec-typedarraysetelement It should only throw if Object.defineProperty is used and the TA is detached or OOB if a RAB is used. Fixes: #645
saghul
added a commit
that referenced
this issue
Nov 7, 2024
Relevant spec section: https://tc39.es/ecma262/multipage/ordinary-and-exotic-objects-behaviours.html#sec-typedarraysetelement It should only throw if Object.defineProperty is used and the TA is detached or OOB if a RAB is used. Fixes: #645
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
QuickJS has an unexpected behavior (at least when compared with other JS engines), where it throws when a typed array is attempting to be set at a index that is out of bounds:
Compared to other runtimes:
I believe the relevant part of the spec is here:
TypedArraySetElement
It's not super clear to be if this is technically incorrect behavior or not (that is, I see that the function may result in a throw completion, but I don't see where that would happen based on the steps described).
I also found this 10 year old mailing list thread which seems relevant (but never seemed to reach a conclusion): https://esdiscuss.org/topic/should-assigning-to-out-of-bounds-elements-of-a-typed-array-throw-in-strict-mode-code
In practice, this is making the
__toBinary()
function defined by esbuild throw this out of bounds error in certain cases,For reference:
My vote would be to remove this behavior from QuickJS and make the behavior match other JS engines.
The text was updated successfully, but these errors were encountered: