-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Normative: IsDetachedBuffer should be checked before accessing [[ArrayLength]] #2207
Normative: IsDetachedBuffer should be checked before accessing [[ArrayLength]] #2207
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Every other call to IsValidIntegerIndex
is preceded by this call, so it makes sense to do it here as well. That said, it would perhaps make sense to move the IsDetachedBuffer
check into IsValidIntegerIndex
, so as to avoid this problem.
Added a commit to address #2164 (comment) and temporarily removed |
6d1e652
to
f744988
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, these both look right to me.
Per editor call: let's call this normative, but we'll land it without consensus on the belief that it was intended to be a part of #2164. @rkirsling we also think it makes sense to move move the |
Done. Thanks for your patience. 🙇 |
864a25d
to
7ea0ac9
Compare
A recent change to ECMA262 inserted an invocation of IsDetachedBuffer into the modified algorithm. Update the proposal to accommodate that change and more faithfully describe the change will which take place when the proposal is merged. [1] tc39/ecma262#2207
A recent change to ECMA262 inserted an invocation of IsDetachedBuffer into the modified algorithm. Update the proposal to accommodate that change and more faithfully describe the change will which take place when the proposal is merged. [1] tc39/ecma262#2207
It's probably wrong to call this editorial, but it's a fix for an oversight in #2164.
Integer-indexed [[DefineOwnProperty]] is the only place where IsValidIntegerIndex is checked without being immediately preceded by an IsDetachedBuffer check, and I believe this to be a mistake.
The issue is that IsValidIntegerIndex checks [[ArrayLength]] of the typed array itself, which is unaffected by calling DetachArrayBuffer. This seems very silly and may warrant a more significant refactor, but the immediate fix is to avoid calling IsValidIntegerIndex on a typed array with a detached buffer.