mirror of
				https://github.com/roc-lang/roc.git
				synced 2025-11-03 22:13:35 +00:00 
			
		
		
		
	Allow union lambdas to have duplicates
This commit is contained in:
		
							parent
							
								
									8fb9ccccfe
								
							
						
					
					
						commit
						ca87faa906
					
				
					 2 changed files with 7 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -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…
	
	Add table
		Add a link
		
	
		Reference in a new issue