Skip to content

Commit

Permalink
fix(Inference): Consider shunted metas when comparing equality (#555)
Browse files Browse the repository at this point in the history
When comparing for equality of metavars, we need to consider that they
might have been merged to form a new meta, so
`UnificationContext::resolve` must be used. In this case, the variable
(LHS) is updated to the merged value in
`UnificationContext::merge_equal_metas` so we don't need to resolve that
one.
  • Loading branch information
croyzor authored Sep 26, 2023
1 parent 6bc8994 commit ee719d0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/extension/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,13 @@ impl UnificationContext {
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()),
// If `m` has been merged, [`self.variables`] entry
// will have already been updated to the merged
// value by [`self.merge_equal_metas`] so we don't
// need to worry about resolving it.
Constraint::Plus(x, other_m) if m == self.resolve(*other_m) => {
Some(x.clone())
}
_ => None,
},
));
Expand Down

0 comments on commit ee719d0

Please sign in to comment.