Repository navigation
Rewrite shadowed globals in a single walk - #8772
Conversation
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 36de1f79d7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## perf-lam-size #8772 +/- ##
================================================
Coverage ? 80.66%
================================================
Files ? 463
Lines ? 62758
Branches ? 0
================================================
Hits ? 50623
Misses ? 12135
Partials ? 0
🚀 New features to boost your workflow:
|
|
@codex review |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
rescript
@rescript/belt
@rescript/darwin-arm64
@rescript/darwin-x64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
Js_pass_external_shadow walked each lexical declaration's value once more for its own name, so nested declarations were walked once per enclosing one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Christoph Knittel <ck@cca.io>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Christoph Knittel <ck@cca.io>
Covers a reference inside two nested initializers and one in a sibling closure after the inner initializer (same JS as before the change). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Christoph Knittel <ck@cca.io>
f9c7df7 to
477b2fc
Compare
* Rewrite shadowed globals in a single walk Js_pass_external_shadow walked each lexical declaration's value once more for its own name, so nested declarations were walked once per enclosing one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Christoph Knittel <ck@cca.io> * Add CHANGELOG entry Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Christoph Knittel <ck@cca.io> * Test globals shadowed by nested let bindings Covers a reference inside two nested initializers and one in a sibling closure after the inner initializer (same JS as before the change). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Christoph Knittel <ck@cca.io> --------- Signed-off-by: Christoph Knittel <ck@cca.io> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Pedro Castro <aspeddro@gmail.com>
…n scope Backport of rescript-lang#8785 to 12.x. A reference to a @Val global compiled to its bare name, which reads a binding with that name if one is in scope. Previously this was only handled inside the binding's own initializer. The cases of a switch share one scope, and the discriminant is read outside of it. Differences from master: - 12.x has no rescript-lang#8772, which replaced the per-binding rewrite of an initializer with a single walk; rescript-lang#8785 replaces that code as a whole, so the pass here is master's rescript-lang#8785 version without rescript-lang#8772 in between, and rescript-lang#8772's ExternalShadow tests are not included. - 12.x's J.ForRange has five fields and there is no ForOf or ForAwaitOf. - Js_call_info.na_full_call takes the transformed-JSX flag on 12.x. - ppx_apply_test.mjs: 12.x already printed the toplevel `xx` unsuffixed, so only the read of the global changes to `globalThis.xx` (on 12.x it read the local `xx = 6`). Signed-off-by: Rob <illusionalsagacity@users.noreply.github.com>
Stacked on #8771.
Js_pass_external_shadowrewrites a reference to a JS global inside the initializer of a lexical binding with the same name (let foo = foowould hit the TDZ, so it becomesglobalThis.foo). For every lexical declaration it walked the initializer once more to do that rewrite, and then walked it again as part of the normal traversal. A declaration nested d levels deep was therefore walked d + 1 times.The pass now does a single walk and keeps the names of the enclosing lexical bindings while it traverses their initializers; a JS-global reference whose name is in that set is rewritten. That is the same set of rewrites as before, since the separate walks rewrote by name anywhere inside the initializer, including nested functions.
Measurements
Same method as #8769, compared with the previous PR in the stack. Every benchmark file compiles to byte-identical JS and diagnostics, including
ExternalShadow.resandExternalScopeShadow.res.letclosures🤖 Generated with Claude Code