Skip to content

Normative: WeakRef.prototype.constructor should be writable #3638

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
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

anba
Copy link
Contributor

@anba anba commented Jul 7, 2025

This matches how all other constructor properties are defined and implementations also implement the property as writable.

@anba
Copy link
Contributor Author

anba commented Jul 7, 2025

This matches how all other `constructor` properties are defined and
implementations also implement the property as writable.
Copy link
Member

@michaelficarra michaelficarra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to remind myself what the default property descriptor was for these. From ECMAScript Standard Built-in Objects

Every other data property described in clauses 19 through 28 and in Annex B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.

LGTM editorially but I've yet to confirm the claimed implementation reality. I also want to double check with the other editors that this wasn't done for a reason.

@michaelficarra michaelficarra added the editor call to be discussed in the next editor call label Jul 7, 2025
@jmdyck
Copy link
Collaborator

jmdyck commented Jul 8, 2025

This matches how all other constructor properties are defined

Not quite all. The constructor property has [[Writable]]: *false* for each of these:

  • AsyncFunction.prototype
  • AsyncGeneratorFunction.prototype
  • AsyncGeneratorPrototype
  • GeneratorFunction.prototype
  • GeneratorPrototype

WeakRef.prototype does look like an odd man out though.

@ljharb
Copy link
Member

ljharb commented Jul 8, 2025

Notably, all of those are "hidden intrinsics", only reachable from syntax, except for WeakRef. cc @erights

@bakkot
Copy link
Contributor

bakkot commented Jul 8, 2025

WeakRef.prototype.constructor is definitely special; among other things it is normative optional (as per tc39/proposal-weakrefs#133). But I don't know if there was some reason it was made non-writable, especially given that it is configurable.

@erights
Copy link

erights commented Jul 8, 2025

I know why we made it normative optional. I don't remember anything about its writability one way or the other, but it may have just been following the precedent of those above. Yes, they are reachable from syntax and this is not. But I don't know why reachability-from-syntax should imply anything about the writability of those either. Does anyone have a way to easily find the notes from when any of these were discussed?

@erights
Copy link

erights commented Jul 8, 2025

Attn @kriskowal @gibson042 @mhofman

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editor call to be discussed in the next editor call
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants