Skip to content

byteOffset is reset to 0 for detached array buffers #417

@nickva

Description

@nickva

Tried to update to the latest test262 commit in #408 and noticed a failure in the new byteOffset test: byteoffset-with-detached-buffer

In assert.sameValue(byteOffset, 2 * TA.BYTES_PER_ELEMENT); byteOffset is 8 and not 16 as the test expects.

In QuickJS we zero the byteOffset if the buffer is detached, but oddly enough, the spec doesn't call for that: [13. Let srcByteOffset be O.[[ByteOffset]]](https://tc39.es/ecma262/#sec-%typedarray%.prototype.subarray). A bit higher in If [IsTypedArrayOutOfBounds](https://tc39.es/ecma262/#sec-istypedarrayoutofbounds)(srcRecord) is true we notice the buffer is detached but that just sets the srcLength = 0 and doesn't throw an error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions