Skip to content

[immutable-arraybuffer] TypedArray internal operations#4551

Open
gibson042 wants to merge 16 commits into
tc39:mainfrom
gibson042:2025-07-immutable-arraybuffer-typedarray-internal-operations
Open

[immutable-arraybuffer] TypedArray internal operations#4551
gibson042 wants to merge 16 commits into
tc39:mainfrom
gibson042:2025-07-immutable-arraybuffer-typedarray-internal-operations

Conversation

@gibson042
Copy link
Copy Markdown
Member

@gibson042 gibson042 commented Jul 29, 2025

Ref #4509

%TypedArray% instance operations

  • [[GetOwnProperty]]

    • property descriptors for in-bounds indexes of a typed array backed by an immutable ArrayBuffer are reported as writable false, enumerable true, configurable false
  • [[DefineOwnProperty]]

    • attempts to redefine own properties for in-bounds indexes of a typed array backed by an immutable ArrayBuffer are validated against descriptors for immutable properties
      • presence of writable: true, enumerable: false, configurable: true, get, and/or set results in rejection
      • presence of value with any value that is not treated as identical to the current value by Object.is results in rejection (e.g., value: -0 and value: "0" are rejected when the current value is 0)
      • all other property descriptors (e.g., any subset of { writable: false, enumerable: true, configurable: false, value: $currentValue }) are accepted but do not result in observable changes
  • [[Set]]

    • any attempt to set the value for a property whose name is a canonical numeric index string (including non-index values such as "-0", "1.5", "590295810358705700000", "5e-324", "1.7976931348623157e+308", "Infinity", and "NaN") on a typed array backed by an immutable ArrayBuffer is rejected, even if the new value is identical to the current value
    • likewise for attempts on a receiver having such a typed array in its prototype chain when the [[Set]] makes it to the typed array

Most of the changes just relax filters applied to testWithTypedArrayConstructors and similar harness/testTypedArray.js exports such that immutable ArrayBuffers are no longer excluded.

@gibson042 gibson042 requested a review from a team as a code owner July 29, 2025 16:35
@gibson042 gibson042 force-pushed the 2025-07-immutable-arraybuffer-typedarray-internal-operations branch from 55e9cb7 to 795f516 Compare August 1, 2025 01:35
var value1 = sample[1];
assert.compareArray([String(value0), String(value1)], ["42", "43"]);

verifyProperty(sample, "0", {
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.

Note that verifyProperty() is based on various assumptions that don't work for typed arrays. For example, isWritable(new Uint8Array(8), "0") is false (incorrectly) and isWritable(new BigInt64Array(8), "0") even results in SyntaxError: Cannot convert unlikelyValue to a BigInt.

The current version of the test seems to be lucky to pass despite the usage of verifyProperty(), but it is probably better to avoid it (for typed arrays). Note that, for example, index-prop-desc.js that is kind of mutable version of this test avoids verifyProperty() for the mentioned reasons.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I just fixed verifyProperty to work with TypedArray input.

includes: [testTypedArray.js, compareArray.js, propertyHelper.js]
---*/

testWithAllTypedArrayConstructors(function(TA, makeCtorArg) {
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.

Other tests in the same directory do not test BigInt typed arrays i.e. use testWithTypedArrayConstructors instead of testWithAllTypedArrayConstructors (and contain a variant with testWithBigIntTypedArrayConstructors in BigInt sub-directory).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Right, in the long term I'll be removing the "bigint" sub-directories to make the testing more consolidated.

@gibson042 gibson042 force-pushed the 2025-07-immutable-arraybuffer-typedarray-internal-operations branch from 795f516 to 0fa24b7 Compare May 8, 2026 00:21
gibson042 added a commit to gibson042/test262 that referenced this pull request May 8, 2026
@gibson042 gibson042 force-pushed the 2025-07-immutable-arraybuffer-typedarray-internal-operations branch from 0fa24b7 to c8acdac Compare May 8, 2026 01:40
@gibson042 gibson042 requested a review from ptomato May 8, 2026 01:42
@ptomato
Copy link
Copy Markdown
Contributor

ptomato commented May 15, 2026

Needs a non-trivial rebase.

@gibson042 gibson042 force-pushed the 2025-07-immutable-arraybuffer-typedarray-internal-operations branch from c8acdac to 3be710d Compare May 17, 2026 17:21
@gibson042
Copy link
Copy Markdown
Member Author

Needs a non-trivial rebase.

Done.

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.

3 participants