From 0b343b1de03af60b30fe7e58af5ba855a8885cbb Mon Sep 17 00:00:00 2001 From: Craig Roy Date: Tue, 26 Sep 2023 09:35:03 +0100 Subject: [PATCH 1/2] fix(Inference): Consider shunted metas when comparing equality --- src/extension/infer.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/extension/infer.rs b/src/extension/infer.rs index c12ca05bd..9d0b7e0a1 100644 --- a/src/extension/infer.rs +++ b/src/extension/infer.rs @@ -664,7 +664,9 @@ 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()), + Constraint::Plus(x, other_m) if m == self.resolve(*other_m) => { + Some(x.clone()) + } _ => None, }, )); From b43c788e457f0322340526f51fe61887cee6bdd9 Mon Sep 17 00:00:00 2001 From: Craig Roy Date: Tue, 26 Sep 2023 10:20:28 +0100 Subject: [PATCH 2/2] doc: Add a comment from the PR description --- src/extension/infer.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/extension/infer.rs b/src/extension/infer.rs index 9d0b7e0a1..f9f2f1751 100644 --- a/src/extension/infer.rs +++ b/src/extension/infer.rs @@ -664,6 +664,10 @@ impl UnificationContext { let solution = ExtensionSet::from_iter(self.get_constraints(&m).unwrap().iter().filter_map( |c| match c { + // 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()) }