Skip to content

Commit da5208c

Browse files
committed
Rename contains_free to binds_rigid_var
1 parent 446bcc1 commit da5208c

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

fathom/src/core.rs

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ impl<'arena> Term<'arena> {
216216
}
217217
}
218218

219-
pub fn contains_free(&self, mut var: LocalVar) -> bool {
219+
/// Returns `true` if the term contains an occurrence of the rigid variable.
220+
pub fn binds_rigid_var(&self, mut var: LocalVar) -> bool {
220221
match self {
221222
Term::RigidVar(_, v) => *v == var,
222223
Term::ItemVar(_, _)
@@ -226,32 +227,34 @@ impl<'arena> Term<'arena> {
226227
| Term::Prim(_, _)
227228
| Term::ConstLit(_, _) => false,
228229

229-
Term::Ann(_, term, r#type) => term.contains_free(var) || r#type.contains_free(var),
230+
Term::Ann(_, term, r#type) => term.binds_rigid_var(var) || r#type.binds_rigid_var(var),
230231
Term::Let(_, _, r#type, def, body) => {
231-
r#type.contains_free(var)
232-
|| def.contains_free(var)
233-
|| body.contains_free(var.prev())
232+
r#type.binds_rigid_var(var)
233+
|| def.binds_rigid_var(var)
234+
|| body.binds_rigid_var(var.prev())
234235
}
235236
Term::FunType(_, _, input_type, output_type) => {
236-
input_type.contains_free(var) || output_type.contains_free(var.prev())
237+
input_type.binds_rigid_var(var) || output_type.binds_rigid_var(var.prev())
237238
}
238-
Term::FunLit(_, _, body) => body.contains_free(var.prev()),
239-
Term::FunApp(_, head, arg) => head.contains_free(var) || arg.contains_free(var),
239+
Term::FunLit(_, _, body) => body.binds_rigid_var(var.prev()),
240+
Term::FunApp(_, head, arg) => head.binds_rigid_var(var) || arg.binds_rigid_var(var),
240241
Term::RecordType(_, _, terms)
241242
| Term::RecordLit(_, _, terms)
242243
| Term::FormatRecord(_, _, terms)
243244
| Term::FormatOverlap(_, _, terms) => terms.iter().any(|term| {
244-
let result = term.contains_free(var);
245+
let result = term.binds_rigid_var(var);
245246
var = var.prev();
246247
result
247248
}),
248-
Term::RecordProj(_, term, _) => term.contains_free(var),
249-
Term::ArrayLit(_, terms) => terms.iter().any(|term| term.contains_free(var)),
250-
Term::FormatCond(_, _, t1, t2) => t1.contains_free(var) || t2.contains_free(var.prev()),
249+
Term::RecordProj(_, term, _) => term.binds_rigid_var(var),
250+
Term::ArrayLit(_, terms) => terms.iter().any(|term| term.binds_rigid_var(var)),
251+
Term::FormatCond(_, _, t1, t2) => {
252+
t1.binds_rigid_var(var) || t2.binds_rigid_var(var.prev())
253+
}
251254
Term::ConstMatch(_, scrut, branches, default) => {
252-
scrut.contains_free(var)
253-
|| branches.iter().any(|(_, term)| term.contains_free(var))
254-
|| default.map_or(false, |term| term.contains_free(var.prev()))
255+
scrut.binds_rigid_var(var)
256+
|| branches.iter().any(|(_, term)| term.binds_rigid_var(var))
257+
|| default.map_or(false, |term| term.binds_rigid_var(var.prev()))
255258
}
256259
}
257260
}

fathom/src/surface/distillation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ impl<'interner, 'arena, 'env> Context<'interner, 'arena, 'env> {
370370
}
371371
core::Term::Universe(_span) => Term::Universe(()),
372372
core::Term::FunType(_span, _, input_type, output_type)
373-
if !output_type.contains_free(LocalVar::last()) =>
373+
if !output_type.binds_rigid_var(LocalVar::last()) =>
374374
{
375375
let input_type = self.check(input_type);
376376

0 commit comments

Comments
 (0)