Skip to content

Read Math, JSON and Reflect as real objects in JavaScript - #2006

Merged
ctate merged 5 commits into
mainfrom
ctate/read-math-json-7723ad
Oct 25, 2026
Merged

ctate merged 5 commits into
mainfrom
ctate/read-math-json-7723ad

Conversation

@ctate

@ctate ctate commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator
  • In JavaScript, Math, JSON and Reflect used as values are now objects with Node's own properties, attributes and Symbol.toStringTag. Before, they were a string token: typeof, String, in, descriptors and member calls through an alias all differed from Node.
  • Replacing or deleting one of their function members throws SC1090, because static member calls keep their direct lowerings.
  • test262: Math 432→458, JSON 136→144 and Reflect 50→92 passing, with no regressions.

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.
@vercel

vercel Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
scriptc Ready Ready Preview, v0 Oct 25, 2026 2:16am UTC

Comment thread packages/compiler/src/frontend/lowering/builtin-namespaces.ts
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).
@ctate
ctate merged commit 7b946ff into main Oct 25, 2026
59 of 65 checks passed
@ctate
ctate deleted the ctate/read-math-json-7723ad branch October 25, 2026 02:50

This branch was successfully deployed

1 active deployment
Preview — 8f6f8929 Deployed Oct 25, 2026 by vercel[bot]
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.

1 participant