Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Normative: Fix detach check for TypedArray.prototype.transfer #99

Merged
merged 3 commits into from
Jul 19, 2022

Conversation

syg
Copy link
Collaborator

@syg syg commented Jul 11, 2022

Closes #98

@bakkot
Copy link
Contributor

bakkot commented Jul 18, 2022

I note that this order (coerce argument, then check for detachedness) is inconsistent with TypedArray.prototype.at, which does the detachedness check before the argument coercion.

But I don't actually care, this seems fine.

@syg
Copy link
Collaborator Author

syg commented Jul 18, 2022

I note that this order (coerce argument, then check for detachedness) is inconsistent with TypedArray.prototype.at, which does the detachedness check before the argument coercion.

This is true. In at, if the parameter coercion detaches the buffer, it's "fine" to not do a second detach check because there's a reasonable behavior even for detached buffers: return undefined.

In transfer, the operation itself needs to detach the source buffer after transferring, so it needs to know for sure the buffer is attached before continuing. Putting the detached check before the parameter coercion means we do one before then another one right after, which seems... not very useful?

@bakkot
Copy link
Contributor

bakkot commented Jul 18, 2022

Yeah, works for me. Just wanted to note the inconsistency.

@syg
Copy link
Collaborator Author

syg commented Jul 19, 2022

This got consensus at the July TC39 plenary.

@syg syg merged commit 17b2feb into master Jul 19, 2022
@syg syg deleted the missing-detach-in-prototype-transfer branch July 19, 2022 18:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

transfer is missing a detach check after converting parameter
2 participants