Repository navigation
fix(javascript): keep a call whose argument prints as a value in the one pass - #22974
alexander-akait wants to merge 2 commits into
Conversation
…one pass A call printed as its function's value prints each parameter as the name passed for it, which a moved function, a folded value or an inlined constant no longer declares: such a call prints as written. Claude-Session: https://claude.ai/code/session_01Tgxgyb4N35ndP6cC4KcrXC
|
|
This PR is packaged and the instant preview of its latest commit is available. Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@22974
yarn add -D webpack@https://pkg.pr.new/webpack@22974
pnpm add -D webpack@https://pkg.pr.new/webpack@22974 |
Types CoverageCoverage after merging fix/javascript-one-pass-reduced-arguments into main will be
Coverage Report |
Generated code sizeComparing base (
Read No asset changed size. No runtime gained or lost a runtime module. Built |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Argument checks and validation lib/javascript/syntax-printer.js, test/unitCases/javascript/printer.unittest.js |
The printer cancels the function reduction, call reduction, and parameter substitutions when an argument is moved, collapsed, or inlined. A test covers nested calls with function, number, and object arguments. |
Suggested labels: area: parser
Suggested reviewers: aryanraj45
Priority:
Change: Bug fix
Merge Risk: 
Minimal · previous review b2910
-
No actionable merge-blocking risk was identified.
Pre-merge checks: 
4
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
Merging this PR will improve performance by 70.33%1 warning, 1 note
Performance Changes
Tip Curious why performance improved? Comment Comparing |
…ss-reduced-arguments # Conflicts: # lib/javascript/syntax-printer.js # test/unitCases/javascript/printer.unittest.js
|
Closing: this fix is already on Generated by Claude Code |
Summary
The one pass prints a simple call as its function's value (#22956), each parameter as the name passed. When that name's read prints something else instead (a function moved to it, a folded value, an inlined constant), its declaration is gone and the output reads an undefined name. Such a call now prints as written.
Sizes over lodash, three, acorn, babel-parser, prettier and terser are unchanged (455,533 B gzip), and the 672 terser
expect_stdoutcases still print the same. No changeset: #22956 is not released yet.What kind of change does this PR introduce?
fix
Did you add tests for your changes?
Yes, a row in the one-pass table in
test/unitCases/javascript/printer.unittest.jswith a moved function, an inlined constant and a folded object passed.Does this PR introduce a breaking change?
No.
If relevant, what needs to be documented once your changes are merged or what have you already documented?
n/a
Use of AI
Written with Claude Code: it found the bug while checking the one pass for shadowed names, wrote the failing test first, then the fix, and ran the printer unit tests, the terser behavior cases and lint.
Generated by Claude Code
Summary by CodeRabbit