@@ -917,7 +917,7 @@ impl InferCtx {
917917 . collect ( ) ;
918918
919919 // Unify the argument with the instantiated param
920- self . state . unify ( span, & arg_ty, & instantiated_param) ?;
920+ self . state . unify ( arg . span ( ) , & arg_ty, & instantiated_param) ?;
921921
922922 // Post-check 1: verify no forall var leaked into ambient vars' solutions.
923923 // Catches escapes like `\x -> foo x` where x's type gets constrained
@@ -988,15 +988,15 @@ impl InferCtx {
988988
989989 let result_ty = Type :: Unif ( self . state . fresh_var ( ) ) ;
990990 let expected_func_ty = Type :: fun ( arg_ty, result_ty. clone ( ) ) ;
991- self . state . unify ( span, & func_ty, & expected_func_ty) ?;
991+ self . state . unify ( arg . span ( ) , & func_ty, & expected_func_ty) ?;
992992
993993 Ok ( result_ty)
994994 }
995995
996996 fn infer_if (
997997 & mut self ,
998998 env : & Env ,
999- span : crate :: span:: Span ,
999+ _span : crate :: span:: Span ,
10001000 cond : & Expr ,
10011001 then_expr : & Expr ,
10021002 else_expr : & Expr ,
@@ -1009,7 +1009,7 @@ impl InferCtx {
10091009
10101010 let then_ty = self . infer ( env, then_expr) ?;
10111011 let else_ty = self . infer ( env, else_expr) ?;
1012- self . state . unify ( span, & then_ty, & else_ty) ?;
1012+ self . state . unify ( else_expr . span ( ) , & then_ty, & else_ty) ?;
10131013
10141014 if is_underscore {
10151015 Ok ( Type :: fun ( Type :: boolean ( ) , then_ty) )
@@ -1725,7 +1725,11 @@ impl InferCtx {
17251725
17261726 // Infer the body and unify with result type
17271727 let body_ty = self . infer_guarded ( & alt_env, & alt. result ) ?;
1728- self . state . unify ( span, & result_ty, & body_ty) ?;
1728+ let body_span = match & alt. result {
1729+ GuardedExpr :: Unconditional ( e) => e. span ( ) ,
1730+ GuardedExpr :: Guarded ( _) => alt. span ,
1731+ } ;
1732+ self . state . unify ( body_span, & result_ty, & body_ty) ?;
17291733 }
17301734
17311735 // Exhaustiveness check: for each scrutinee, verify all constructors are covered
@@ -1782,14 +1786,14 @@ impl InferCtx {
17821786 fn infer_array (
17831787 & mut self ,
17841788 env : & Env ,
1785- span : crate :: span:: Span ,
1789+ _span : crate :: span:: Span ,
17861790 elements : & [ Expr ] ,
17871791 ) -> Result < Type , TypeError > {
17881792 let elem_ty = Type :: Unif ( self . state . fresh_var ( ) ) ;
17891793
17901794 for elem in elements {
17911795 let t = self . infer ( env, elem) ?;
1792- self . state . unify ( span, & elem_ty, & t) ?;
1796+ self . state . unify ( elem . span ( ) , & elem_ty, & t) ?;
17931797 }
17941798
17951799 Ok ( Type :: array ( elem_ty) )
@@ -2193,7 +2197,7 @@ impl InferCtx {
21932197
21942198 // Apply: func expr (\_ -> rest)
21952199 let after_first = Type :: Unif ( self . state . fresh_var ( ) ) ;
2196- self . state . unify ( span, & func_ty, & Type :: fun ( expr_ty, after_first. clone ( ) ) ) ?;
2200+ self . state . unify ( expr . span ( ) , & func_ty, & Type :: fun ( expr_ty, after_first. clone ( ) ) ) ?;
21972201 let discard_arg = Type :: Unif ( self . state . fresh_var ( ) ) ;
21982202 let cont_ty = Type :: fun ( discard_arg, rest_ty) ;
21992203 let result = Type :: Unif ( self . state . fresh_var ( ) ) ;
@@ -2223,7 +2227,7 @@ impl InferCtx {
22232227
22242228 // Apply: bind expr (\binder -> rest)
22252229 let after_first = Type :: Unif ( self . state . fresh_var ( ) ) ;
2226- self . state . unify ( span, & func_ty, & Type :: fun ( expr_ty, after_first. clone ( ) ) ) ?;
2230+ self . state . unify ( expr . span ( ) , & func_ty, & Type :: fun ( expr_ty, after_first. clone ( ) ) ) ?;
22272231 let cont_ty = Type :: fun ( binder_ty, rest_ty) ;
22282232 let result = Type :: Unif ( self . state . fresh_var ( ) ) ;
22292233 self . state . unify ( span, & after_first, & Type :: fun ( cont_ty, result. clone ( ) ) ) ?;
0 commit comments