Allow union lambdas to have duplicates

This commit is contained in:
Ayaz Hafiz 2022-06-27 13:07:22 -04:00 committed by ayazhafiz
parent 8fb9ccccfe
commit ca87faa906
No known key found for this signature in database
GPG Key ID: B443F7A3030C9AED
2 changed files with 7 additions and 4 deletions

View File

@ -2650,11 +2650,14 @@ impl<L> UnionLabels<L>
where
L: Label + Ord,
{
pub fn is_sorted_no_duplicates(&self, subs: &Subs) -> bool {
/// Checks if the union of labels is sorted by label.
/// Duplicates *are* admitted, since this represents a lambda set, in which we may have
/// duplicate lambda captures, if those lambda captures have different representations!
pub fn is_sorted(&self, subs: &Subs) -> bool {
let mut iter = self.iter_from_subs(subs).peekable();
while let Some((before, _)) = iter.next() {
if let Some((after, _)) = iter.peek() {
if before >= after {
if before > after {
return false;
}
}

View File

@ -1506,8 +1506,8 @@ fn separate_union_lambdas(
fields1: UnionLambdas,
fields2: UnionLambdas,
) -> Separate<Symbol, VariableSubsSlice> {
debug_assert!(fields1.is_sorted_no_duplicates(subs));
debug_assert!(fields2.is_sorted_no_duplicates(subs));
debug_assert!(fields1.is_sorted(subs));
debug_assert!(fields2.is_sorted(subs));
let it1 = fields1.iter_all().map(|(s, vars)| (subs[s], subs[vars]));
let it2 = fields2.iter_all().map(|(s, vars)| (subs[s], subs[vars]));