From ee719d037351d5dde0917e425589d235cddf1003 Mon Sep 17 00:00:00 2001 From: Craig Roy Date: Tue, 26 Sep 2023 10:22:54 +0100 Subject: [PATCH] fix(Inference): Consider shunted metas when comparing equality (#555) 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. --- src/extension/infer.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/extension/infer.rs b/src/extension/infer.rs index c12ca05bd..f9f2f1751 100644 --- a/src/extension/infer.rs +++ b/src/extension/infer.rs @@ -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, }, ));