Skip to content

Commit

Permalink
fix: Extension validation for looping graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
croyzor committed Sep 22, 2023
1 parent bf6ffee commit 9310da9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/extension/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,17 @@ impl UnificationContext {
pub fn instantiate_variables(&mut self) {
for m in self.variables.clone().into_iter() {
if !self.solved.contains_key(&m) {
self.add_solution(m, ExtensionSet::new());
// Handle the case where the constraints for `m` contain a self
// reference, i.e. "m = Plus(E, m)", in which case the variable
// should be instantiated to E rather than the empty set.
let solution =
ExtensionSet::from_iter(self.get_constraints(&m).unwrap().iter().filter_map(
|c| match c {
Constraint::Plus(x, other_m) if &m == other_m => Some(x.clone()),
_ => None,
},
));
self.add_solution(m, solution);
}
}
self.variables = HashSet::new();
Expand Down

0 comments on commit 9310da9

Please sign in to comment.