Skip to content

Commit

Permalink
fix: has_free_vars was broken under applications
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentElement committed May 30, 2024
1 parent 3bc1afd commit 49aa964
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/term.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ impl Term {
Abs(p) => p.has_free_variables_helper(depth + 1),
App(p_boxed) => {
let (ref f, ref a) = **p_boxed;
f.has_free_variables_helper(depth) && a.has_free_variables_helper(depth)
f.has_free_variables_helper(depth) || a.has_free_variables_helper(depth)
}
}
}
Expand Down Expand Up @@ -744,6 +744,15 @@ mod tests {
fn has_free_variables() {
assert!(!(abs(Var(1)).has_free_variables()));
assert!(abs(Var(2)).has_free_variables());
assert!(app(abs(Var(2)), Var(1)).has_free_variables());
assert!(app(abs(Var(2)), abs(Var(1))).has_free_variables());
assert!(app(abs(Var(1)), abs(Var(2))).has_free_variables());
assert!(!app(abs(Var(1)), abs(Var(1))).has_free_variables());
assert!(!(abs(app(
abs(app(Var(2), app(Var(1), Var(1)))),
abs(app(Var(2), app(Var(1), Var(1)))),
)))
.has_free_variables());
assert!((Var(0)).has_free_variables());
}
}

0 comments on commit 49aa964

Please sign in to comment.