Repository navigation
Read Math, JSON and Reflect as real objects in JavaScript - #2006
Merged
Merged
Conversation
In JavaScript sources, Math, JSON or Reflect read as a value lowered to an identity token, the string "[builtin Math]": typeof, String, `in`, descriptors and member calls through an alias all had string semantics. Each of these namespaces read as a value is now one object per program, built on first use, with Node 24's own properties in Node's order: function members are writable, configurable and non-enumerable with Node's `length`, the Math constants are read-only, and Symbol.toStringTag names the namespace. Members hold the same function values the spelled member read gives; a member without one throws its fence when called. Global reads, globalThis, destructuring and shorthand properties all produce the same object, and an object with a string Symbol.toStringTag coerces to "[object <tag>]". Direct member calls keep their static lowerings, so replacing or deleting a function member would not reach them: such changes throw SC1090. New properties and attribute-only redefinitions behave as in Node.
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Reading `ownKeys` from Reflect read as a value (`const r = Reflect; r.ownKeys`) gave the member function that throws SC1090 when called, although the spelled `Reflect.ownKeys` read already has a function value. The namespace object now holds that function value, so calls through the alias run and `r.ownKeys === Reflect.ownKeys` is true, as in Node. The spelled read and the namespace member share one lowering (reflectMemberValue).
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Math,JSONandReflectused as values are now objects with Node's own properties, attributes andSymbol.toStringTag. Before, they were a string token: typeof, String,in, descriptors and member calls through an alias all differed from Node.