Repository navigation
Conversation
Member
Author
|
Fixes from review (a371dd8, ee26617):
Regression tests added. |
This was referenced Oct 29, 2026
…nd let instead of var
…a rest param named var_args isn't declared again (const and let can't be redeclared)
… locals' declaration, filled in once, instead of copying their bodies at every level
Member
Author
|
Restacked on
The review-fix merges are folded into the branches' own commits. The code is unchanged apart from #21's changes. Only On every branch, |
k7d
marked this pull request as ready for review
October 30, 2026 12:09
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.
In ES module output, locals inside functions are now declared with
const, or withletwhen they're reassigned, instead ofvar. Module-level vars stayvar, since hot reloads anddefonceassign them. Classic output is unchanged.Motivation: tools that analyze the compiled JavaScript reject functions that use
var. React Compiler is the main one (Handle var kinds in VariableDeclaration). Block-scoped declarations are also simply the modern default.Changes (ES module output only)
letbindings,letfn,recurtemporaries, variadic delegates andself__becomeconst. Loop locals,caseresults, variadic rest args and assigned bindings (assign-tails) becomelet.emit-let) are declared withletat the start of the function. Before, they were avarat the end, which relied on hoisting. The body is written to a buffer until the hoisted locals are known; the declaration sits on the line of the opening brace, so source maps are unaffected.case: each clause is wrapped in a{}block, since aswitchshares one scope and two clauses declaring the sameconstwould clash.self__parameter: when a parameter is already namedself__(the IFn methods of multi-arity fns), it's assigned instead of redeclared.cljs.proxy: dropped its(js* "var __ctor"). It was only needed forvarsemantics;__ctoris aletbinding.unsafe-cast: returns its value unchanged in ES module output. The cast is only a Closure type annotation, and assigning to the argument fails when it's aconstlocal.React Compiler
With
babel-plugin-react-compiler1.0 (compilationMode: 'all') on a test namespace, components usinglet, destructuring,case,loopand hooks now compile; before, any function with a local was rejected. Components usingforare still rejected, because the iterator fn calls itself by its function-expression name. That's a follow-up. Components still need to be marked or detected as components; this PR doesn't do that.Performance
cljs.corebenchmarks (release build bundled with rolldown, Node 26, 5 interleaved runs each, medians) are neutral: total +0.7%, geometric mean of the ratios for benchmarks taking at least 10 ms is 1.014. One JS-array.mapbenchmark measured about 2x on the branch, but its timings swing between about 18 and 40 ms on both builds, so it's probably noise; not confirmed.Tests
script/test-esm: 0 failures, 0 errors. It includes a new build test that the output has novarin functions, that loop and hoisted locals areletand the restconst, thatcaseclauses are blocks, and that the output runs correctly.clojure -M:closure:compiler.test:compiler.test.run): 0 failures, 0 errors. Classic output is unchanged.