Skip to content

Commit

Permalink
seminaive transform for replace
Browse files Browse the repository at this point in the history
  • Loading branch information
oflatt committed Sep 8, 2023
1 parent 4176de6 commit c9b20c0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/ast/desugar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,17 @@ fn add_semi_naive_rule(desugar: &mut Desugar, rule: Rule) -> Option<Rule> {
new_head_atoms.push(Fact::Eq(vec![fresh_var, expr]));
};
}
Action::Replace { new_output, .. } => {
var_set.extend(new_output.vars());
if let Expr::Call(_, _) = new_output {
add_new_rule = true;

let fresh_symbol = desugar.get_fresh();
let fresh_var = Expr::Var(fresh_symbol);
let new_output = std::mem::replace(new_output, fresh_var.clone());
new_head_atoms.push(Fact::Eq(vec![fresh_var, new_output]));
};
}
Action::Let(symbol, expr) if var_set.contains(symbol) => {
var_set.extend(expr.vars());
if let Expr::Call(_, _) = expr {
Expand Down

0 comments on commit c9b20c0

Please sign in to comment.