Skip to content

Commit

Permalink
Rename current variable
Browse files Browse the repository at this point in the history
  • Loading branch information
imaqtkatt committed Jun 24, 2024
1 parent c23952f commit 042773a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/fun/transform/desugar_match_defs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,10 @@ fn num_rule(
let mut body = rule.body.clone();
if let Some(var) = var {
let last_num = *nums.last().unwrap();
let curr_num = 1 + last_num;
let var_recovered = Term::add_num(Term::Var { nam: pred_var.clone() }, Num::U24(curr_num));
let cur_num = 1 + last_num;
let var_recovered = Term::add_num(Term::Var { nam: pred_var.clone() }, Num::U24(cur_num));
body = Term::Use { nam: Some(var.clone()), val: Box::new(var_recovered), nxt: Box::new(body) };
fast_pred_access(&mut body, curr_num, var, &pred_var);
fast_pred_access(&mut body, cur_num, var, &pred_var);
}
let rule = Rule { pats: rule.pats[1..].to_vec(), body };
new_rules.push(rule);
Expand Down Expand Up @@ -345,19 +345,19 @@ fn num_rule(

/// Replaces `body` to `pred_var` if the term is a operation that subtracts the given var by the current
/// switch number.
fn fast_pred_access(body: &mut Term, curr_num: u32, var: &Name, pred_var: &Name) {
fn fast_pred_access(body: &mut Term, cur_num: u32, var: &Name, pred_var: &Name) {
maybe_grow(|| {
if let Term::Oper { opr: crate::fun::Op::SUB, fst, snd } = body {
if let Term::Num { val: crate::fun::Num::U24(val) } = &**snd {
if let Term::Var { nam } = &**fst {
if nam == var && *val == curr_num {
if nam == var && *val == cur_num {
*body = Term::Var { nam: pred_var.clone() };
}
}
}
}
for child in body.children_mut() {
fast_pred_access(child, curr_num, var, pred_var)
fast_pred_access(child, cur_num, var, pred_var)
}
})
}
Expand Down

0 comments on commit 042773a

Please sign in to comment.