-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
perf(es/compat): Merge optional_catch_binding
#11313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: kdy1/object-rest-spread
Are you sure you want to change the base?
Conversation
|
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Code Review: perf(es/compat): Merge optional catch bindingSummaryThis PR attempts to merge the optional catch binding transformation into the new transformer architecture. However, there is a critical bug: the transformation logic has been completely removed, making this a breaking change that will cause the feature to stop working. 🚨 Critical Issues1. Missing Implementation (BLOCKING)Location: The new implementation is completely empty: pub fn hook() -> impl VisitMutHook<TraverseCtx> {
OptionalCatchBindingPass {}
}
struct OptionalCatchBindingPass {}
impl VisitMutHook<TraverseCtx> for OptionalCatchBindingPass {}The old implementation (now removed from fn visit_mut_catch_clause(&mut self, cc: &mut CatchClause) {
cc.visit_mut_children_with(self);
if cc.param.is_some() {
return;
}
cc.param = Some(private_ident!("e").into());
}Impact: Optional catch binding transformation will not work at all. Code like Fix Required: The new hook implementation must override the impl VisitMutHook<TraverseCtx> for OptionalCatchBindingPass {
fn enter_catch_clause(&mut self, node: &mut CatchClause, _ctx: &mut TraverseCtx) {
if node.param.is_none() {
node.param = Some(private_ident!("e").into());
}
}
}2. Test Failures (BLOCKING)Location: The test code still references the old implementation: use crate::optional_catch_binding::OptionalCatchBinding;
pub fn tr() -> impl Pass {
(
resolver(Mark::new(), Mark::new(), false),
visit_mut_pass(OptionalCatchBinding),
)
}Issue: Fix Required: Tests should use the new public API ( 3. Missing Hook Registration in OptionalHook (POTENTIAL ISSUE)Location: The
It does not implement // TODO: Implement lots of hooks, or move it to `swc_ecma_hooks`Impact: Even if you implement Fix Required: Add optional_method!(enter_catch_clause, exit_catch_clause, CatchClause);Other Issues4. Inconsistent Dependency DirectionLocation: Adding
Recommendation: Consider fully migrating this transform to 5. Missing DocumentationPer CLAUDE.md guideline #7: "Write documentation for your code." The new hook implementation has no documentation explaining:
Performance ConsiderationsThe PR title mentions "perf" but there's no evidence of performance improvement:
Recommendation: After fixing the implementation, provide benchmark results showing the performance improvement from merging this pass. Test Coverage❌ Tests are broken - they reference deleted code ( Required:
Security Concerns✅ No security issues identified - this is a straightforward AST transformation. Recommendations
Verdict❌ CHANGES REQUESTED - This PR cannot be merged in its current state due to the missing implementation and broken tests. The refactoring approach is good, but the execution is incomplete. Once the transformation logic is implemented and tests are fixed, this should be ready for merge. |
eae6bee to
d29b1c5
Compare
11ab642 to
3faf520
Compare
optional_catch_binding
CodSpeed Performance ReportMerging #11313 will not alter performanceComparing Summary
|
Code Review: PR #11313 - perf(es/compat): Merge
|
Pull Request ReviewThank you for working on this performance optimization! The goal of merging 🚨 Critical Issues1. Missing Implementation LogicThe new implementation in Location: struct OptionalCatchBindingPass {}
impl VisitMutHook<TraverseCtx> for OptionalCatchBindingPass {}Problem: The actual transformation logic that adds a parameter to catch clauses without bindings has been removed from the old implementation but not added to the new one. Expected: The hook needs to implement the impl VisitMutHook<TraverseCtx> for OptionalCatchBindingPass {
fn enter_catch_clause(&mut self, cc: &mut CatchClause, _ctx: &mut TraverseCtx) {
if cc.param.is_none() {
cc.param = Some(private_ident!("e").into());
}
}
}2. OptionalHook Doesn't Support CatchClauseThe Location: Problem: Solution: Either:
3. Broken Test ReferencesThe test file still references the old Location: use crate::optional_catch_binding::OptionalCatchBinding;
// ...
visit_mut_pass(OptionalCatchBinding),Problem: This will cause compilation errors because 📋 Code Quality Issues4. Missing DocumentationPer CLAUDE.md rule #7, the new code should have documentation explaining what it does. Location: Recommendation: Add module-level documentation: //! ES2019: Optional catch binding
//!
//! Transforms catch clauses without bindings into catch clauses with a parameter.
//! This allows `try {} catch {}` to work in environments that don't support ES2019.
5. Missing Unit TestsPer CLAUDE.md rule #5, new code should have unit tests. The transformation logic should be tested in the new location. 🔍 Testing ConcernsCritical: The existing tests will fail because:
Recommendation: Run the tests before submitting: cargo test --package swc_ecma_compat_es2019 optional_catch_binding✅ What's Good
🛠️ Action Items
Would you like help implementing these fixes? |
Binary Sizes
Commit: 946461d |
Code Review: PR #11313 - perf(es/compat): Merge
|
3faf520 to
c05e51b
Compare
52002f3 to
985051b
Compare
PR Review: Merge
|
Code Review for PR #11313: perf(es/compat): Merge
|
985051b to
fae3ece
Compare
c05e51b to
a04ca12
Compare
Pull Request Review: perf(es/compat): Merge
|
Code Review for PR #11313Thank you for working on merging the Critical Issues1. Incorrect Dependency Version ❌Location: swc_ecma_transformer = { version = "0.1.0", path = "../swc_ecma_transformer" }Issue: The version is specified as Fix: Change the version to swc_ecma_transformer = { version = "1.0.0", path = "../swc_ecma_transformer" }2. Broken Tests ❌Location: The tests still reference the deleted use crate::optional_catch_binding::OptionalCatchBinding;
pub fn tr() -> impl Pass {
(
resolver(Mark::new(), Mark::new(), false),
visit_mut_pass(OptionalCatchBinding), // This no longer exists!
)
}Issue: According to CLAUDE.md guideline #6: "When instructed to fix tests, do not remove or modify existing tests." The tests are now broken because they reference a deleted type. Fix: The tests should be updated to use the new API: pub fn tr() -> impl Pass {
(
resolver(Mark::new(), Mark::new(), false),
super::optional_catch_binding(),
)
}Major Concerns3. Changed Identifier Name (Potential Breaking Change)
|
a04ca12 to
4d80d34
Compare
fae3ece to
7854d97
Compare
Pull Request Review - PR #11313SummaryThis PR refactors the Issues Found🔴 Critical: Incorrect Dependency VersionLocation: swc_ecma_transformer = { version = "0.1.0", path = "../swc_ecma_transformer" }Problem: The dependency specifies version Fix: Update to the correct version: swc_ecma_transformer = { version = "1.0.0", path = "../swc_ecma_transformer" }
|
Code Review for PR #11313: perf(es/compat): Merge
|

Description:
BREAKING CHANGE:
Related issue (if exists):