Skip to content

[immutable-arraybuffer] Coverage for mutating TypedArray methods#4548

Merged
gibson042 merged 3 commits into
tc39:mainfrom
gibson042:2025-07-immutable-arraybuffer-typedarray-methods-readwrite
May 17, 2026
Merged

[immutable-arraybuffer] Coverage for mutating TypedArray methods#4548
gibson042 merged 3 commits into
tc39:mainfrom
gibson042:2025-07-immutable-arraybuffer-typedarray-methods-readwrite

Conversation

@gibson042
Copy link
Copy Markdown
Member

@gibson042 gibson042 commented Jul 24, 2025

Ref #4509

%TypedArray%.prototype properties

  • %TypedArray%.prototype.{copyWithin,fill,reverse,set}

    • throws a TypeError if the receiver is backed by an immutable ArrayBuffer, before touching any argument
    • ...even if the targeted range is of length 0
  • %TypedArray%.prototype.sort

    • throws a TypeError if the receiver is backed by an immutable ArrayBuffer, after validating that comparator is callable (note the unusual receiver-after-argument order)
    • ...even if the receiver is of length 0
  • Uint8Array.prototype.{setFromBase64,setFromHex}

    • throws a TypeError if the receiver is backed by an immutable ArrayBuffer, before touching any argument

@gibson042 gibson042 requested a review from a team as a code owner July 24, 2025 18:01
@gibson042 gibson042 changed the title 2025 07 immutable arraybuffer typedarray methods readwrite [immutable-arraybuffer] Coverage for mutating TypedArray methods Jul 24, 2025
@ptomato ptomato force-pushed the 2025-07-immutable-arraybuffer-typedarray-methods-readwrite branch from c5c7a89 to a3cd36e Compare August 25, 2025 22:30
@gibson042 gibson042 force-pushed the 2025-07-immutable-arraybuffer-typedarray-methods-readwrite branch from a3cd36e to 3c8505d Compare May 8, 2026 15:17
@gibson042 gibson042 requested a review from ptomato May 8, 2026 15:30
Copy link
Copy Markdown
Contributor

@ptomato ptomato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments, feel free to merge when addressed.

Comment on lines +22 to +29
var calls = [];

var ta = new TA(makeCtorArg(["1", "2", "3", "4"]));

assert.throws(TypeError, function() {
ta.reverse();
});
assert.compareArray(calls, [], "Must verify mutability before reading arguments.");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There aren't any arguments to read, or any reentrancy into user code at all for that matter, so this is a bit overkill. Maybe delete calls and its assertion?

@gibson042 gibson042 force-pushed the 2025-07-immutable-arraybuffer-typedarray-methods-readwrite branch from f719ae1 to aa7484e Compare May 17, 2026 17:08
@gibson042 gibson042 enabled auto-merge (squash) May 17, 2026 17:08
@gibson042 gibson042 merged commit 78fc3f8 into tc39:main May 17, 2026
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants