mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-22 08:17:40 +03:00
Allow union lambdas to have duplicates
This commit is contained in:
parent
8fb9ccccfe
commit
ca87faa906
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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]));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user