Skip to content

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

Description

@anba

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions