Commits

camlspotter committed db6b82b

record expression points to its type

  • Participants
  • Parent commits 3893d8e

Comments (0)

Files changed (4)

     open Typedtree
     open Abstraction
 
+    let record_record loc typ = 
+      let open Types in
+      let open Ctype in
+      match (repr typ).desc with
+      | Tconstr (path, _, _) -> record loc (Use (Kind.Type, path)) 
+      | _ -> (* strange.. *) ()
+
     class fold = object (self)
       inherit Ttfold.fold as super
 
       method! pattern p = 
         record p.pat_loc (Type (p.pat_type, p.pat_env, `Pattern));
+        begin match p.pat_desc with
+        | Tpat_record _ -> record_record p.pat_loc p.pat_type
+        | _ -> ()
+        end;
         super#pattern p
 
     (* CR jfuruse: pat_extra *)
       
       method! expression e = 
         record e.exp_loc (Type (e.exp_type, e.exp_env, `Expr));
+        begin match e.exp_desc with
+        | Texp_record _ -> record_record e.exp_loc e.exp_type
+        | _ -> ()
+        end;
         super#expression e
 
 (*

File tests/class2.mli

-module M0 : sig
+module (* M0 => *) M0 (* <= M0 *) : sig
   class (* M0.c => *) c (* <= M0.c *): object end 
 end
-(* <= M0 *)
 
 module Test : sig
   val v : M0.c (* ? M0.c *)

File tests/target_e.ml

+let _ = Target.E (* ? Target.E *)
+
+let _ = try true with Target.E (* ? Target.E *) -> false

File tests/test13.ml

 
 let _ = 
   match { y = 1 } (* ? type x *) with
-  | { y = (* n => *) n (* <= n *) } (* ? type x *) -> n (* ? n *)
+  | { y (* ? x.y *) = (* n => *) n (* <= n *) } (* ? type x *) -> n (* ? n *)
 
 let _ = x(* ? x *).y (* ? x.y *) 
 
 
 let _ = (1 : int)
 
-type (* type tt => *) 'a tt = Null | Cons of 'a * 'a (* ? type tt *) tt 
-(* <= type tt *)
+type 'a (* type tt => *) tt (* <= type tt *) = Null | Cons of 'a * 'a tt (* ? type tt *) 
+
 
 type 'a uu = Foo of 'a vv (* ? type vv *)
 and 'a (* type vv => *) vv (* <= type vv *) = Bar of 'a uu