Skip to content

Commit 1a69ee1

Browse files
committed
Make variable bindings more consistent
Cleans up some of the variable bindings to be more consistent with the rest of Fathom. It might be worth considering renaming some of these, but for now I think it’s probably better to be consistent!
1 parent da5208c commit 1a69ee1

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

fathom/src/core.rs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -227,17 +227,19 @@ impl<'arena> Term<'arena> {
227227
| Term::Prim(_, _)
228228
| Term::ConstLit(_, _) => false,
229229

230-
Term::Ann(_, term, r#type) => term.binds_rigid_var(var) || r#type.binds_rigid_var(var),
231-
Term::Let(_, _, r#type, def, body) => {
232-
r#type.binds_rigid_var(var)
233-
|| def.binds_rigid_var(var)
234-
|| body.binds_rigid_var(var.prev())
230+
Term::Ann(_, expr, r#type) => expr.binds_rigid_var(var) || r#type.binds_rigid_var(var),
231+
Term::Let(_, _, def_type, def_expr, output_expr) => {
232+
def_type.binds_rigid_var(var)
233+
|| def_expr.binds_rigid_var(var)
234+
|| output_expr.binds_rigid_var(var.prev())
235235
}
236236
Term::FunType(_, _, input_type, output_type) => {
237237
input_type.binds_rigid_var(var) || output_type.binds_rigid_var(var.prev())
238238
}
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),
239+
Term::FunLit(_, _, output_expr) => output_expr.binds_rigid_var(var.prev()),
240+
Term::FunApp(_, head_expr, input_expr) => {
241+
head_expr.binds_rigid_var(var) || input_expr.binds_rigid_var(var)
242+
}
241243
Term::RecordType(_, _, terms)
242244
| Term::RecordLit(_, _, terms)
243245
| Term::FormatRecord(_, _, terms)
@@ -246,15 +248,17 @@ impl<'arena> Term<'arena> {
246248
var = var.prev();
247249
result
248250
}),
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())
251+
Term::RecordProj(_, head_expr, _) => head_expr.binds_rigid_var(var),
252+
Term::ArrayLit(_, elem_exprs) => {
253+
elem_exprs.iter().any(|term| term.binds_rigid_var(var))
254+
}
255+
Term::FormatCond(_, _, format, pred) => {
256+
format.binds_rigid_var(var) || pred.binds_rigid_var(var.prev())
253257
}
254-
Term::ConstMatch(_, scrut, branches, default) => {
258+
Term::ConstMatch(_, scrut, branches, default_expr) => {
255259
scrut.binds_rigid_var(var)
256260
|| branches.iter().any(|(_, term)| term.binds_rigid_var(var))
257-
|| default.map_or(false, |term| term.binds_rigid_var(var.prev()))
261+
|| default_expr.map_or(false, |term| term.binds_rigid_var(var.prev()))
258262
}
259263
}
260264
}

0 commit comments

Comments
 (0)