@@ -149,11 +149,11 @@ impl EffectSet {
149149 }
150150
151151 pub fn try_unify_with_bindings < ' c > (
152- & self , other : & EffectSet , bindings : & mut UnificationBindings , location : Location < ' c > ,
152+ & self , expected : & EffectSet , bindings : & mut UnificationBindings , location : Location < ' c > ,
153153 cache : & mut ModuleCache < ' c > ,
154154 ) -> Result < ( ) , ( ) > {
155155 let a = self . follow_unification_bindings ( bindings, cache) ;
156- let b = other . follow_unification_bindings ( bindings, cache) ;
156+ let b = expected . follow_unification_bindings ( bindings, cache) ;
157157
158158 let mut new_effects_in_a = Vec :: new ( ) ;
159159 let mut new_effects_in_b = Vec :: new ( ) ;
@@ -185,8 +185,10 @@ impl EffectSet {
185185 check_effects ( & a. effects , & b. effects , & mut new_effects_in_b) ;
186186 check_effects ( & b. effects , & a. effects , & mut new_effects_in_a) ;
187187
188- if a. extension . is_none ( ) && !new_effects_in_a. is_empty ( )
189- || b. extension . is_none ( ) && !new_effects_in_b. is_empty ( )
188+ // Allow extra effects in `a` (actual) if `b` (expected) has extra,
189+ // but not the reverse. This allows, e.g. passing a pure function
190+ // into a function expecting a function with an effect.
191+ if b. extension . is_none ( ) && !new_effects_in_b. is_empty ( )
190192 {
191193 return Err ( ( ) ) ;
192194 }
@@ -208,7 +210,11 @@ impl EffectSet {
208210 }
209211 } ;
210212
211- let a_extension = extend_effects ( new_effects_in_a, a. extension ) ?;
213+ let a_extension = match a. extension {
214+ Some ( extension) => extend_effects ( new_effects_in_a, Some ( extension) ) ?,
215+ None => None ,
216+ } ;
217+
212218 let b_extension = extend_effects ( new_effects_in_b, b. extension ) ?;
213219
214220 if let ( Some ( a) , Some ( b) ) = ( a_extension, b_extension) {
0 commit comments