Skip to content

Commit

Permalink
live_var: look harder for Plus constraint on itself
Browse files Browse the repository at this point in the history
  • Loading branch information
acl-cqc committed Oct 30, 2023
1 parent 37b84a8 commit 6d4b446
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/extension/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,14 +574,23 @@ impl UnificationContext {
// TODO: We should be doing something to ensure that these are the same check...
if self.get_solution(m).is_none() {
if let Some(cs) = self.get_constraints(m) {
for c in cs {
match c {
Constraint::Plus(_, m) => return self.live_var(m),
let other_ms = cs
.iter()
.map(|c| match c {
Constraint::Plus(_, other_m) => *other_m,
_ => panic!("we shouldn't be here!"),
}
}
})
.collect::<Vec<_>>();
// Ideally, we should properly detect cycles. TODO.
if other_ms.contains(&m) {
// If iteration order happened to pick that element,
// we'd have an infinite loop
panic!("Node is Plus on itself")
};
other_ms.iter().filter_map(|m| self.live_var(m)).next()
} else {
Some(*m)
}
Some(*m)
} else {
None
}
Expand Down

0 comments on commit 6d4b446

Please sign in to comment.