Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
anba opened this issue May 20, 2025 · 0 comments
Open

Comments

@anba
Copy link

anba commented May 20, 2025

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant