Repository navigation
ES module output: destructure #js [] arrays by index - #16
Merged
Merged
Conversation
Member
Author
|
Fixes from review (fdba401):
The test now covers each case. |
k7d
force-pushed
the
esm-destructure-arrays
branch
from
October 30, 2026 07:27
fdba401 to
2316608
Compare
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
force-pushed
the
esm-destructure-arrays
branch
from
October 30, 2026 12:40
2316608 to
458872c
Compare
… array reads it by index in ES module output
k7d
force-pushed
the
esm-destructure-arrays
branch
from
October 30, 2026 13:05
458872c to
c97bad1
Compare
k7d
marked this pull request as ready for review
October 30, 2026 13:31
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.
Based on
main.In ES module output, sequential destructuring of a
letlocal that certainly holds a JavaScript array reads it by index,(v?.[i] ?? null), instead of callingnth. The result is the same asnth's: the element within the array's bounds,nilpast its end.What counts as an array: only a
letlocal bound to a#js []literal (cljs.analyzer/js-array-init?). Everything else goes throughnthas before:recurcan rebind to other values;^array(a hinted param that gets a vector would break);React's array-returning hooks (
useStateand the like) are added tojs-array-init?in #17, with the rest of the React Compiler logic.Performance
Micro-benchmark (release build, rolldown-minified, Node 26, 3 runs):
Tests
script/test-esm: 0 failures, 0 errors. A new build test checks that#js []literals are read by index (nilpast their end), that vectors, other JS calls, loop locals and^arrayhints go throughnth, and that the output runs correctly.