Skip to content

Commit 9d61f71

Browse files
Brooooooklynclaude
andcommitted
fix: remaining _unnamed_N variable references and missing Animation handler_ops
- Add 7 missing expression types (Not, Unary, Typeof, Void, ResolvedTemplateLiteral, ArrowFunction, Parenthesized) to visit_all_expressions in variable_optimization.rs, fixing incorrect context variable inlining when expressions like `!(x)` wrapped ReadVariable references - Add CreateOp::Animation handler_ops traversal to resolve_contexts, next_context_merging, allocate_slots, strip_nonrequired_parentheses, and regular_expression_optimization phases - Add TwoWayListener/AnimationListener to regular_expression_optimization Eliminates all _unnamed_N occurrences across 5846 compiled ClickUp files. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent fe7dc68 commit 9d61f71

10 files changed

Lines changed: 352 additions & 9 deletions

crates/oxc_angular_compiler/src/pipeline/phases/allocate_slots.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,11 @@ fn propagate_slots_to_expressions(
802802
update_op_expression_slots(handler_op, slot_map);
803803
}
804804
}
805+
CreateOp::Animation(animation) => {
806+
for handler_op in animation.handler_ops.iter_mut() {
807+
update_op_expression_slots(handler_op, slot_map);
808+
}
809+
}
805810
_ => {}
806811
}
807812
}
@@ -825,6 +830,11 @@ fn propagate_slots_to_expressions(
825830
update_op_expression_slots(handler_op, slot_map);
826831
}
827832
}
833+
CreateOp::Animation(animation) => {
834+
for handler_op in animation.handler_ops.iter_mut() {
835+
update_op_expression_slots(handler_op, slot_map);
836+
}
837+
}
828838
_ => {}
829839
}
830840
}

crates/oxc_angular_compiler/src/pipeline/phases/next_context_merging.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ pub fn merge_next_context_expressions(job: &mut ComponentCompilationJob<'_>) {
4242
CreateOp::AnimationListener(listener) => {
4343
merge_next_contexts_in_handler_ops(&mut listener.handler_ops);
4444
}
45+
CreateOp::Animation(animation) => {
46+
merge_next_contexts_in_handler_ops(&mut animation.handler_ops);
47+
}
4548
_ => {}
4649
}
4750
}

crates/oxc_angular_compiler/src/pipeline/phases/regular_expression_optimization.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,21 @@ fn collect_and_pool_regexes_from_create_op<'a>(
110110
collect_and_pool_regexes_from_update_op(handler_op, pool, replacements);
111111
}
112112
}
113+
CreateOp::TwoWayListener(listener) => {
114+
for handler_op in listener.handler_ops.iter() {
115+
collect_and_pool_regexes_from_update_op(handler_op, pool, replacements);
116+
}
117+
}
118+
CreateOp::AnimationListener(listener) => {
119+
for handler_op in listener.handler_ops.iter() {
120+
collect_and_pool_regexes_from_update_op(handler_op, pool, replacements);
121+
}
122+
}
123+
CreateOp::Animation(animation) => {
124+
for handler_op in animation.handler_ops.iter() {
125+
collect_and_pool_regexes_from_update_op(handler_op, pool, replacements);
126+
}
127+
}
113128
_ => {}
114129
}
115130
}
@@ -187,6 +202,21 @@ fn transform_regexes_in_create_op<'a>(
187202
transform_regexes_in_update_op(handler_op, allocator, replacements);
188203
}
189204
}
205+
CreateOp::TwoWayListener(listener) => {
206+
for handler_op in listener.handler_ops.iter_mut() {
207+
transform_regexes_in_update_op(handler_op, allocator, replacements);
208+
}
209+
}
210+
CreateOp::AnimationListener(listener) => {
211+
for handler_op in listener.handler_ops.iter_mut() {
212+
transform_regexes_in_update_op(handler_op, allocator, replacements);
213+
}
214+
}
215+
CreateOp::Animation(animation) => {
216+
for handler_op in animation.handler_ops.iter_mut() {
217+
transform_regexes_in_update_op(handler_op, allocator, replacements);
218+
}
219+
}
190220
_ => {}
191221
}
192222
}

crates/oxc_angular_compiler/src/pipeline/phases/resolve_contexts.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,16 @@ fn process_lexical_scope_create<'a>(
112112
&mut None,
113113
);
114114
}
115+
CreateOp::Animation(animation) => {
116+
// Animation has no handler_expression
117+
process_listener_handler_ops(
118+
allocator,
119+
view_xref,
120+
is_root,
121+
&mut animation.handler_ops,
122+
&mut None,
123+
);
124+
}
115125
_ => {
116126
transform_expressions_in_create_op(
117127
op,

crates/oxc_angular_compiler/src/pipeline/phases/strip_nonrequired_parentheses.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ fn visit_expressions_for_required_parens(
120120
visit_update_expressions_for_required_parens(handler_op, required);
121121
}
122122
}
123+
CreateOp::Animation(a) => {
124+
for handler_op in a.handler_ops.iter() {
125+
visit_update_expressions_for_required_parens(handler_op, required);
126+
}
127+
}
123128
CreateOp::AnimationString(a) => {
124129
check_ir_expression_for_required_parens(&a.expression, required);
125130
}

crates/oxc_angular_compiler/src/pipeline/phases/variable_optimization.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,13 @@ fn collect_create_op_fences(op: &CreateOp<'_>) -> Fence {
362362
}
363363
fences
364364
}
365+
CreateOp::Animation(animation) => {
366+
let mut fences = Fence::NONE;
367+
for handler_op in animation.handler_ops.iter() {
368+
fences |= collect_op_fences(handler_op);
369+
}
370+
fences
371+
}
365372
// DeclareLet doesn't have expressions at the create phase
366373
CreateOp::DeclareLet(_) => Fence::NONE,
367374
_ => Fence::NONE,
@@ -522,6 +529,13 @@ fn inline_always_inline_in_listener_handler_ops<'a>(
522529
allocator,
523530
);
524531
}
532+
CreateOp::Animation(animation) => {
533+
inline_always_inline_in_handler_ops_and_expr(
534+
&mut animation.handler_ops,
535+
None, // Animation doesn't have handler_expression
536+
allocator,
537+
);
538+
}
525539
CreateOp::RepeaterCreate(repeater) => {
526540
if let Some(track_by_ops) = &mut repeater.track_by_ops {
527541
inline_always_inline_in_handler_ops_and_expr(track_by_ops, None, allocator);
@@ -1408,6 +1422,29 @@ where
14081422
visit_all_expressions(value, visitor);
14091423
}
14101424
}
1425+
IrExpression::Not(n) => {
1426+
visit_all_expressions(&n.expr, visitor);
1427+
}
1428+
IrExpression::Unary(u) => {
1429+
visit_all_expressions(&u.expr, visitor);
1430+
}
1431+
IrExpression::Typeof(t) => {
1432+
visit_all_expressions(&t.expr, visitor);
1433+
}
1434+
IrExpression::Void(v) => {
1435+
visit_all_expressions(&v.expr, visitor);
1436+
}
1437+
IrExpression::ResolvedTemplateLiteral(rtl) => {
1438+
for e in rtl.expressions.iter() {
1439+
visit_all_expressions(e, visitor);
1440+
}
1441+
}
1442+
IrExpression::ArrowFunction(arrow_fn) => {
1443+
visit_all_expressions(&arrow_fn.body, visitor);
1444+
}
1445+
IrExpression::Parenthesized(paren) => {
1446+
visit_all_expressions(&paren.expr, visitor);
1447+
}
14111448
// Leaf expressions
14121449
_ => {}
14131450
}
@@ -2215,6 +2252,11 @@ fn count_in_create_op(op: &CreateOp<'_>, counts: &mut HashMap<XrefId, usize>) {
22152252
count_in_update_op(handler_op, counts);
22162253
}
22172254
}
2255+
CreateOp::Animation(animation) => {
2256+
for handler_op in animation.handler_ops.iter() {
2257+
count_in_update_op(handler_op, counts);
2258+
}
2259+
}
22182260
CreateOp::Conditional(_cond) => {
22192261
// ConditionalOp (CREATE) no longer has test/branches/processed_expression.
22202262
// Those are now on ConditionalUpdateOp (UPDATE) and handled in count_in_update_op.
@@ -2994,6 +3036,11 @@ fn transform_expressions_in_create_op<'a, F>(
29943036
transform_expressions_in_update_op(handler_op, allocator, &mut transform);
29953037
}
29963038
}
3039+
CreateOp::Animation(animation) => {
3040+
for handler_op in animation.handler_ops.iter_mut() {
3041+
transform_expressions_in_update_op(handler_op, allocator, &mut transform);
3042+
}
3043+
}
29973044
CreateOp::RepeaterCreate(rep) => {
29983045
let new_expr = transform_expression(&rep.track, allocator, &mut transform);
29993046
*rep.track = new_expr;

0 commit comments

Comments
 (0)