Commits

camlspotter  committed 6de6e59

typeloc for poly vars

  • Participants
  • Parent commits 831e03d
  • Branches typeloc

Comments (0)

Files changed (3)

File testsuite/typeloc/pvar.ml

-let _ = `A + 1  (* this is tricky! NG *)
+let _ = `A + 1  (* this is tricky! ok ? *)
 

File testsuite/typeloc/pvar_pat.ml

 let _ = function
-  | `A -> ()  (* NG *)
+  | `A -> ()  (* ok? *)
   | 1 -> ()

File typing/typecore.ml

         pat_type = expected_ty;
         pat_env = !env }
   | Ppat_variant(l, sarg) ->
-      (* CR jfuruse: typeloc todo *)
+      (* CR jfuruse: typeloc todo for sarg *)
       let arg = may_map (fun p -> type_pat p (newvar())) sarg in
       let arg_type = match arg with None -> [] | Some arg -> [arg.pat_type]  in
       let row = { row_fields =
                   row_more = newvar ();
                   row_fixed = false;
                   row_name = None } in
-      unify_pat_types loc !env (newty (Tvariant row)) expected_ty;
+      unify_pat_types loc !env (copy_with_loc loc (newty (Tvariant row))) expected_ty;
       rp {
         pat_desc = Tpat_variant(l, arg, ref {row with row_more = newvar()});
         pat_loc = loc; pat_extra=[];
   | Pexp_construct(lid, sarg, explicit_arity) ->
       type_construct env loc lid sarg explicit_arity ty_expected
   | Pexp_variant(l, sarg) ->
-      (* CR jfuruse: typeloc todo *)
+      (* CR jfuruse: tyloc todo for sarg *)
       (* Keep sharing *)
       let ty_expected0 = instance env ty_expected in
       begin try match
           begin match row_field_repr (List.assoc l row.row_fields),
           row_field_repr (List.assoc l row0.row_fields) with
             Rpresent (Some ty), Rpresent (Some ty0) ->
+              (* tyloc: l is already in the type, so no need of introduce tyloc *)
               let arg = type_argument env sarg ty ty0 in
               re { exp_desc = Texp_variant(l, Some arg);
                    exp_loc = loc; exp_extra = [];
         rue {
           exp_desc = Texp_variant(l, arg);
           exp_loc = loc; exp_extra = [];
-          exp_type= newty (Tvariant{row_fields = [l, Rpresent arg_type];
+          exp_type= copy_with_loc loc 
+                    (newty (Tvariant{row_fields = [l, Rpresent arg_type];
                                     row_more = newvar ();
                                     row_bound = ();
                                     row_closed = false;
                                     row_fixed = false;
-                                    row_name = None});
+                                    row_name = None}));
           exp_env = env }
       end
   | Pexp_record(lid_sexp_list, opt_sexp) ->