No successful run was found on main (e4cdc47) during the generation of this report, so 68d740c was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.
feat(es2015): migrate arrow functions to hook-based architecture
This PR migrates the arrow functions transformation from the legacy
`swc_ecma_compat_es2015` crate to the new hook-based architecture in
`swc_ecma_transformer`.
## Changes
### New Implementation
- Created `swc_ecma_transformer/src/es2015/arrow_functions.rs`
- Implements `VisitMutHook<TraverseCtx>` trait
- Handles `this` and `arguments` binding transformation
- Properly detects usage in arrow function bodies
- Uses `TraverseCtx::statement_injector` for variable injection
### Architecture Updates
- Updated `Es2015Options` to include `arrow_functions: Option<Mark>`
- Wired up the hook in the ES2015 module using `OptionalHook` pattern
- Made `es2015` module public for backward compatibility
### Integration
- Updated `swc_ecma_preset_env` to use the new transformer
- Sets `options.env.es2015.arrow_functions = Some(unresolved_mark)`
- Removed old `es2015::arrow(unresolved_mark)` pass
### Backward Compatibility
- Updated `swc_ecma_compat_es2015` to wrap the new implementation
- Maintains the same public API
- Added dependencies on `swc_ecma_hooks` and `swc_ecma_transformer`
## Pattern
This follows the established pattern from:
- PR #11310: Exponentiation operator migration
- PR #11313: Optional catch binding migration
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
81bca19
2 days ago
by github-actions[bot]
+0.01%
fix: Add exhaustive pattern matching for non-exhaustive enums
Fix compilation errors by adding wildcard arms to match statements
for non-exhaustive enums (BlockStmtOrExpr and PropOrSpread).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
cfde106
2 days ago
by github-actions[bot]
+2.84%
fix: Fix arrow functions transformation by implementing visit_mut_expr in backward compat wrapper
The issue was that the backward compatibility wrapper (arrow.rs) was not
properly forwarding expression visits to the hook. When async_arrows_in_class
called expr.visit_mut_with(), it only implemented visit_mut_program, so the
hook was never invoked for expression-level transformations.
The fix adds a visit_mut_expr implementation that creates a VisitMutWithHook
and properly forwards all expression visits, allowing the arrow functions
transform to work correctly.
Also moved arrow transformation from enter_expr to exit_expr to ensure
children are visited before transformation, and added enter_arrow_expr to
detect this/arguments usage before visiting children.
Note: One edge case test (async_arrows_in_class::tests::this) still fails
due to the backward compatibility wrapper not calling enter_arrow_expr,
but this can be addressed in a follow-up.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
95f072d
2 days ago
by github-actions[bot]
0%
fix: Fix clippy warnings in arrow functions transformation
- Replace `map_or(false, ...)` with `is_some_and(...)` for cleaner code
- Collapse nested pattern matches in object literal handling
- Convert single match statements to if-let for better readability
- Make `check_expr_for_this` a static method to avoid unused self parameter
- Remove unreachable pattern branches for exhaustive matches
- Remove unused imports in backward compatibility wrapper
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
349a257
2 days ago
by github-actions[bot]
-5.12%
fix: Restore old arrow implementation in backward compat wrapper
The backward compatibility wrapper needs to support the old API where
arrow transforms can be applied to expressions in isolation and variables
can be extracted via InjectVars::take_vars(). The new hook-based
implementation uses statement injection which doesn't work for this
use case.
This keeps the old implementation in the compat wrapper for backward
compatibility, while the new hook-based implementation in swc_ecma_transformer
is used for the main transform pipeline.
Fixes test failures in swc_ecma_compat_bugfixes where async_arrows_in_class
transform depends on being able to extract variable declarations.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
fcccaaf
2 days ago
by github-actions[bot]
-0.08%
chore: Fix CI failures - formatting and unused dependencies
- Remove extra blank line in swc_ecma_transformer/src/lib.rs
- Remove unused dependencies (swc_ecma_hooks, swc_ecma_transformer) from swc_ecma_compat_es2015/Cargo.toml
These dependencies were added in preparation but are not yet used in the code, causing cargo shear to fail.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
ad140c9
2 days ago
by github-actions[bot]
-0.01%
chore: Trigger CI rerun
This empty commit triggers a fresh CI run to ensure all checks pass
with the correct formatting that was fixed in the previous commit.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
8c7b305
2 days ago
by github-actions[bot]
+0.02%
fix: Add blank line to match main branch formatting
This ensures the merge commit created by GitHub doesn't introduce
formatting conflicts. The blank line between variable declaration
and return statement matches the style in the main branch.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
094dcd4
2 days ago
by github-actions[bot]
+0.07%
chore: Trigger CI with correct formatting
The lib.rs file is already correctly formatted locally and passes
cargo fmt --all -- --check. This commit triggers a fresh CI run.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
8402f29
2 days ago
by github-actions[bot]
-0.07%
fix: Remove extra blank line in lib.rs to pass cargo fmt
The blank line between variable declaration and return statement
was causing cargo fmt to fail. This follows the standard Rust
formatting style of not having blank lines in short function bodies.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
9629b58
2 days ago
by github-actions[bot]
0%
fix: Add wildcard patterns for non-exhaustive PropOrSpread matches
Fixed compilation errors on nightly Rust by adding wildcard patterns
to PropOrSpread enum matches. The enum is marked as non-exhaustive,
requiring explicit wildcard patterns even though all variants are covered.
Resolves CI build failures in Test - swc_ecma_transforms.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
3552a8a
2 days ago
by github-actions[bot]
0%
fix: Remove unreachable wildcard patterns in arrow_functions.rs
The clippy check was failing due to unreachable wildcard patterns in
PropOrSpread match statements. Since PropOrSpread is an enum with only
two variants (Prop and Spread), which were both explicitly handled, the
wildcard patterns were unreachable.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
f8a511a
2 days ago
by github-actions[bot]
0%
fix: handle non-exhaustive patterns in arrow functions transform
Add wildcard patterns to match statements for non-exhaustive enums
(BlockStmtOrExpr and PropOrSpread) when building with swc_ast_unknown.
This fixes the "Check unknown variant with transforms" CI test.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
bedeea1
2 days ago
by github-actions[bot]
+0.01%
fix(clippy): use cfg attribute for non-exhaustive patterns
Use #[cfg(swc_ast_unknown)] instead of plain wildcard patterns
to avoid unreachable pattern warnings in normal builds while still
handling non-exhaustive enum variants when swc_ast_unknown is enabled.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
9d66132
2 days ago
by github-actions[bot]
+0.01%
fix(es2015): Fix this binding in arrow functions transformation
This commit fixes a critical bug where `this` was being replaced too broadly
during arrow function transformation, causing issues in nested scopes.
The problem was that when an arrow function used `this`, we would create a
`_this` variable and then replace ALL occurrences of `this` in the current
scope, not just those inside the arrow function. This broke code like:
```javascript
class Bar {
test() {
(() => {
expect(this.constructor).toBe(Bar);
})();
}
}
```
The fix introduces an `arrow_depth` counter that tracks when we're inside
an arrow function that needs `this`/`arguments` replacement. We only perform
the replacement when `arrow_depth > 0`, ensuring that `this` is only replaced
within the arrow functions that actually need it.
Fixes 7 failing tests:
- regression_7064
- static_shadow (private and private_loose)
- derived_constructor_must_call_super_3
- super_reference_before_in_lambda (3 variants)
- issues_10xxx__10822__1
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
5a45a90
2 days ago
by github-actions[bot]
-0.02%
fix(es2015): Fix arrow depth tracking for nested arrows
The previous fix had a bug where we would decrement arrow_depth for
every arrow, even if that arrow didn't increment it. This caused issues
with nested arrows where only some use `this`/`arguments`.
Example that was broken:
```javascript
const outer = () => { // doesn't use this
const inner = () => this.value; // uses this
};
```
With the previous fix:
1. Enter outer: depth stays 0 (doesn't use this)
2. Enter inner: depth becomes 1 (uses this)
3. Exit inner: depth becomes 0 ✓
4. Exit outer: depth is 0, but we would decrement if > 0 ✗
The fix adds helper methods to check if an arrow body actually contains
references to the saved `_this` or `_arguments` variables, and only
decrements the depth for arrows that incremented it.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
115024c
2 days ago
by github-actions[bot]
+0.01%
fix: Remove unused self parameter to fix clippy warning
72e8861
2 days ago
by github-actions[bot]
-0.01%
fix(es2015): consolidate arrow expression handling in enter_expr hook
- Move arrow detection logic from enter_arrow_expr to enter_expr
- This ensures child expressions are properly visited by the framework
- Fixes 'this' binding replacement in arrow function bodies
d4f31c1
2 days ago
by github-actions[bot]
-0.02%
fix(es2015): prevent injecting this binding inside arrow body
- Only set cur_stmt_address if not already set in current scope
- This ensures we inject 'var _this = this' before the statement containing the arrow
- Prevents injection inside arrow body (e.g., inside if blocks)
Fixes issue where _this declaration was being injected inside conditional blocks
instead of at the beginning of the enclosing function.