tc39 / tc39/proposal-immutable-arraybuffer

[[DefineOwnProperty]]: Confusing note about redefinition always failing

Open
#52 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
38
Forks
7
PR merge metrics
No merged PRs in 30d

Description

This note in [[DefineOwnProperty]] caused confusion during code view:

NOTE: Attempting to redefine an immutable value always fails, even if the new value would be cast to the current value.


Maybe just inline ValidateAndApplyPropertyDescriptor and replace https://tc39.es/proposal-immutable-arraybuffer/#sec-typedarray-defineownproperty, steps 1.b.ii-viii with:

  1. Let mutable be true.
  2. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, set mutable to false.
  3. If Desc has a [[Configurable]] field and Desc.[[Configurable]] is not mutable, return false.
  4. If Desc has an [[Enumerable]] field and Desc.[[Enumerable]] is false, return false.
  5. If IsAccessorDescriptor(Desc) is true, return false.
  6. If Desc has a [[Writable]] field and Desc.[[Writable]] is not mutable, return false.
  7. If Desc has a [[Value]] field, then
    1. If mutable is false, then
      1. Let current be TypedArrayGetElement(O, numericIndex).
      2. Assert: current is not undefined.
      3. Return SameValue(Desc.[[Value]], current).
    2. Perform ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]).
  8. Return true.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the proposal's [[DefineOwnProperty]] algorithm and the referenced ValidateAndApplyPropertyDescriptor steps in the Immutable ArrayBuffer specification. Compare the current note with the proposed mutable checks and value comparison. Done means the confusing note is replaced by consistent algorithm steps and the linked TypedArray behavior remains accurately specified.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.