tc39 / tc39/proposal-immutable-arraybuffer

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

未关闭
#52 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
JavaScript
星标
38
派生
7
PR 合并指标
30 天内没有已合并 PR

描述

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.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从提案的 [[DefineOwnProperty]] 算法以及 Immutable ArrayBuffer 规范中引用的 ValidateAndApplyPropertyDescriptor 步骤开始。将当前注释与提议的可变性检查和值比较进行对照。完成的标准是:用一致的算法步骤替换令人困惑的注释,并且链接的 TypedArray 行为仍得到准确规范。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript
领域
documentation
Issue 类型
文档
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。