Skip to content

Commit

Permalink
Map exprs without skipping the first one
Browse files Browse the repository at this point in the history
  • Loading branch information
fourst4r committed Feb 11, 2024
1 parent 593d87b commit f8112f6
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/reflaxe/compiler/RepeatVariableFixer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,20 @@ class RepeatVariableFixer {
}

function handleExpression(expr: TypedExpr): TypedExpr {
function mapSubExprs(subExpr: TypedExpr) {
switch(subExpr.expr) {
case TBlock(_): {
return handleBlock(subExpr);
}
case TLocal(tvar): {
final replacement = varReplacement(tvar.id);
if(replacement != null) {
return subExpr.copy(TLocal(replacement));
}
switch(expr.expr) {
case TBlock(_): {
return handleBlock(expr);
}
case TLocal(tvar): {
final replacement = varReplacement(tvar.id);
if(replacement != null) {
return expr.copy(TLocal(replacement));
}
case _:
}
return haxe.macro.TypedExprTools.map(subExpr, mapSubExprs);
case _:
}

return haxe.macro.TypedExprTools.map(expr, mapSubExprs);
return haxe.macro.TypedExprTools.map(expr, handleExpression);
}

function handleBlock(subExpr: TypedExpr): TypedExpr {
Expand Down

0 comments on commit f8112f6

Please sign in to comment.