For TypedArrays read byteOffset before getting start and final #422
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, in issue #418 and pr #417 I misread the spec that in
subarray
we should be able to access thebyteOffset
from a detached buffer. Thinking more about it, something didn't seem right and I started a discussion in the TC39 group [1].It turns out we shouldn't be able to read the
byteOffset
from detched buffers. Instead, the spec says we should just read thebyteOffset
value before we accessstart
andfinish
. In the test262 test [2] the buffer is detached when accessing theend
inside thevalueOf()
conversion, and the test expects to see thebyteOffset
before it was detached.So to fix it, ensure we access and save the
byteOffset
value first, then get thestart
andfinish
.[1] https://es.discourse.group/t/typedarray-subarray-byteoffset-with-detached-buffers/2381
[2] https://github.com/tc39/test262/blob/main/test/built-ins/TypedArray/prototype/subarray/byteoffset-with-detached-buffer.js