Commits

camlspotter committed 9a3b33f

differing_types must seek the bottom of the trace

  • Participants
  • Parent commits 30263de
  • Branches typeloc

Comments (0)

Files changed (1)

File typing/printtyp.ml

 *)
   ()
 
-let differing_types ppf (t, t') =
-  let typ ppf t = match t.tyloc with
-    | Some loc -> 
-        fprintf ppf "@[<v2>  %a : introduced at %a@]" 
-          type_expr t
-          Location.print_loc loc
-    | None -> 
-        fprintf ppf "@[<2>  %a : introduced at unknown place@]" 
-          type_expr t
-  in
-  fprintf ppf "@[<v>The differing types are:@ %a@ %a@]"
-    typ t
-    typ t'
+let rec differing_types ppf = function
+  | [(t,_); (t',_)] ->
+      let typ ppf t = match t.tyloc with
+        | Some loc -> 
+            fprintf ppf "@[<v2>  %a : introduced at %a@]" 
+              type_expr t
+              Location.print_loc loc
+        | None -> 
+            fprintf ppf "@[<2>  %a : introduced at unknown place@]" 
+              type_expr t
+      in
+      fprintf ppf "@[<v>The differing types are:@ %a@ %a@]"
+        typ t
+        typ t'
+  | _::_::tr -> differing_types ppf tr
+  | _ -> assert false
 
 let rec trace fst txt ppf = function
   | (t1, t1') :: (t2, t2') :: rem ->
   trace_same_names tr;
   let tr = List.map (fun (t, t') -> (t, hide_variant_name t')) tr in
   let mis = mismatch unif tr in
+  let tr0 = tr in
   match tr with
   | [] | _ :: [] -> assert false
   | t1 :: t2 :: tr ->
         txt2 (type_expansion t2) t2'
         (trace false "is not compatible with type") tr
         (explanation unif mis)
-        differing_types (t1, t2);
+        differing_types tr0; (* CR jfuruse: we must seek the last trace *)
       print_labels := true
     with exn ->
       print_labels := true;