fix(mangler): keep names for parenthesized functions and classes#13421
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug where the mangler was not properly preserving names for parenthesized function and class expressions. The issue was that expressions wrapped in parentheses (like var a = (function () {})) were not being recognized as function/class expressions that should have their names preserved.
- Updates expression matching logic to look through parentheses when determining if an expression is a function or class
- Adds test cases for parenthesized function expressions, arrow functions, and class expressions
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/oxc_mangler/src/keep_names.rs | Updates the class detection logic to use without_parentheses() and adds test cases for parenthesized expressions |
| crates/oxc_ast/src/ast_impl/js.rs | Updates is_anonymous_function_definition method to look through parentheses when checking expression types |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
CodSpeed Instrumentation Performance ReportMerging #13421 will not alter performanceComparing Summary
Footnotes |
Merge activity
|
) `var a = (function () {})` sets the function name, so these have to be kept as well. https://tc39.es/ecma262/multipage/syntax-directed-operations.html#sec-static-semantics-isfunctiondefinition
2d79c82 to
e3f953d
Compare

var a = (function () {})sets the function name, so these have to be kept as well.https://tc39.es/ecma262/multipage/syntax-directed-operations.html#sec-static-semantics-isfunctiondefinition