Skip to content

[nonextensible-applies-to-private] Adding private field to non-extensible object throws#4577

Merged
ptomato merged 4 commits into
tc39:mainfrom
erights:nonextensible-applies-to-private
Sep 22, 2025
Merged

[nonextensible-applies-to-private] Adding private field to non-extensible object throws#4577
ptomato merged 4 commits into
tc39:mainfrom
erights:nonextensible-applies-to-private

Conversation

@erights
Copy link
Copy Markdown
Contributor

@erights erights commented Sep 10, 2025

Copy link
Copy Markdown
Contributor

@ptomato ptomato left a comment

Choose a reason for hiding this comment

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

Looks correct so far.

For completeness, would we need to test stamping a private accessor and private method?

(I would guess that the case of stamping a private static method, or private static field cannot occur, since those go on the constructor, which cannot be frozen prior to the class declaration.)

Finally, this needs a feature flag for the proposal to be added in features.txt and in the frontmatter of the two modified tests.

@erights
Copy link
Copy Markdown
Contributor Author

erights commented Sep 16, 2025

Looks correct so far.

For completeness, would we need to test stamping a private accessor and private method?

For inheritance, done.

For a base class, AFAICT, impossible. There are no observable states where the class, instance, or prototype are observable before methods are accessors are added.

(I would guess that the case of stamping a private static method, or private static field cannot occur, since those go on the constructor, which cannot be frozen prior to the class declaration.)

For a private static method, AFAICT, it is indeed impossible.

For a private static field, it can be done in the initializer expression. Done.

Finally, this needs a feature flag for the proposal to be added in features.txt and in the frontmatter of the two modified tests.

Done.

(with much help from @gibson042 )

PTAL

@erights erights requested a review from ptomato September 16, 2025 21:09
Copy link
Copy Markdown
Contributor

@ptomato ptomato left a comment

Choose a reason for hiding this comment

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

As far as I can tell complete now, thanks!

@ptomato ptomato force-pushed the nonextensible-applies-to-private branch from f44c974 to 1c60350 Compare September 22, 2025 19:54
@ptomato
Copy link
Copy Markdown
Contributor

ptomato commented Sep 22, 2025

I left this open for a few days in case any other maintainers had any feedback, but now that it's been presented in the TC39 meeting I think it's time to merge it. I'll do that now.

@ptomato ptomato merged commit 822589b into tc39:main Sep 22, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants