Skip to content

Commit 8ee58cd

Browse files
committed
RequirementMachine: Fix assertion in mergeAssociatedTypes()
We used to assert that the merged protocol set was larger than or equal to in size to both the left hand side and the right hand side. However, there is a counter-example: protocol P {} protocol Q {} protocol R : P, Q {} LHS = [P&Q:T], RHS = [R:T] The merged atom is `[R:T]` which has fewer protocols than the left hand side.
1 parent c97d32a commit 8ee58cd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/AST/RequirementMachine/RewriteSystemCompletion.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,9 @@ Atom RewriteSystem::mergeAssociatedTypes(Atom lhs, Atom rhs) const {
202202
}
203203

204204
// The two input sets are minimal already, so the merged set
205-
// should have at least as many elements as each input set.
206-
assert(minimalProtos.size() >= protos.size());
207-
assert(minimalProtos.size() >= otherProtos.size());
205+
// should have at least as many elements as the smallest
206+
// input set.
207+
assert(minimalProtos.size() >= std::min(protos.size(), otherProtos.size()));
208208

209209
// The merged set cannot contain more elements than the union
210210
// of the two sets.

0 commit comments

Comments
 (0)