diff options
author | Jacques Le Normand <rathereasy@gmail.com> | 2010-10-21 08:17:17 +0000 |
---|---|---|
committer | Jacques Le Normand <rathereasy@gmail.com> | 2010-10-21 08:17:17 +0000 |
commit | 87898cb3e919422090d811376f913ff1df0e650a (patch) | |
tree | d4eca2eb61d5772f5db8564d449575e31a8e5713 | |
parent | 10f670297c0112f319b2c33fd4de32748a3de639 (diff) |
internally, we can now refer to constructors with the help of their type, thus avoiding shadowing
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/gadts@10737 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r-- | camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml | 10 | ||||
-rw-r--r-- | camlp4/boot/Camlp4.ml | 10 | ||||
-rw-r--r-- | otherlibs/labltk/browser/searchid.ml | 4 | ||||
-rw-r--r-- | tools/depend.ml | 2 | ||||
-rw-r--r-- | typing/parmatch.ml | 6 |
5 files changed, 17 insertions, 15 deletions
diff --git a/camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml b/camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml index ee587d1bd..89ce6b558 100644 --- a/camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml +++ b/camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml @@ -456,7 +456,7 @@ module Make (Ast : Sig.Camlp4Ast) = struct [ <:patt@loc< $lid:s$ >> -> mkpat loc (Ppat_var s) | <:patt@loc< $id:i$ >> -> let p = Ppat_construct (long_uident ~conv_con i) - None (constructors_arity ()) + None (constructors_arity ()) None in mkpat loc p | PaAli loc p1 p2 -> let (p, i) = @@ -470,21 +470,21 @@ module Make (Ast : Sig.Camlp4Ast) = struct | PaAny loc -> mkpat loc Ppat_any | <:patt@loc< $uid:s$ ($tup:<:patt@loc_any< _ >>$) >> -> mkpat loc (Ppat_construct (lident (conv_con s)) - (Some (mkpat loc_any Ppat_any)) False) + (Some (mkpat loc_any Ppat_any)) False None) | PaApp loc _ _ as f -> let (f, al) = patt_fa [] f in let al = List.map patt al in match (patt f).ppat_desc with - [ Ppat_construct li None _ -> + [ Ppat_construct li None _ _ -> if constructors_arity () then - mkpat loc (Ppat_construct li (Some (mkpat loc (Ppat_tuple al))) True) + mkpat loc (Ppat_construct li (Some (mkpat loc (Ppat_tuple al))) True None) else let a = match al with [ [a] -> a | _ -> mkpat loc (Ppat_tuple al) ] in - mkpat loc (Ppat_construct li (Some a) False) + mkpat loc (Ppat_construct li (Some a) False None) | Ppat_variant s None -> let a = if constructors_arity () then diff --git a/camlp4/boot/Camlp4.ml b/camlp4/boot/Camlp4.ml index 68c781527..3f3182017 100644 --- a/camlp4/boot/Camlp4.ml +++ b/camlp4/boot/Camlp4.ml @@ -14679,7 +14679,7 @@ module Struct = | Ast.PaId (loc, i) -> let p = Ppat_construct ((long_uident ~conv_con i), None, - (constructors_arity ())) + (constructors_arity ()), None) in mkpat loc p | PaAli (loc, p1, p2) -> let (p, i) = @@ -14694,18 +14694,18 @@ module Struct = (Ast.PaTup (_, (Ast.PaAny loc_any)))) -> mkpat loc (Ppat_construct ((lident (conv_con s)), - (Some (mkpat loc_any Ppat_any)), false)) + (Some (mkpat loc_any Ppat_any)), false, None)) | (PaApp (loc, _, _) as f) -> let (f, al) = patt_fa [] f in let al = List.map patt al in (match (patt f).ppat_desc with - | Ppat_construct (li, None, _) -> + | Ppat_construct (li, None, _, _) -> if constructors_arity () then mkpat loc (Ppat_construct (li, - (Some (mkpat loc (Ppat_tuple al))), true)) + (Some (mkpat loc (Ppat_tuple al))), true, None)) else (let a = match al with @@ -14713,7 +14713,7 @@ module Struct = | _ -> mkpat loc (Ppat_tuple al) in mkpat loc - (Ppat_construct (li, (Some a), false))) + (Ppat_construct (li, (Some a), false, None))) | Ppat_variant (s, None) -> let a = if constructors_arity () diff --git a/otherlibs/labltk/browser/searchid.ml b/otherlibs/labltk/browser/searchid.ml index 82cea5ee8..d396f9746 100644 --- a/otherlibs/labltk/browser/searchid.ml +++ b/otherlibs/labltk/browser/searchid.ml @@ -410,8 +410,8 @@ let rec bound_variables pat = | Ppat_var s -> [s] | Ppat_alias (pat,s) -> s :: bound_variables pat | Ppat_tuple l -> List2.flat_map l ~f:bound_variables - | Ppat_construct (_,None,_) -> [] - | Ppat_construct (_,Some pat,_) -> bound_variables pat + | Ppat_construct (_,None,_,_) -> [] + | Ppat_construct (_,Some pat,_,_) -> bound_variables pat | Ppat_variant (_,None) -> [] | Ppat_variant (_,Some pat) -> bound_variables pat | Ppat_record (l, _) -> diff --git a/tools/depend.ml b/tools/depend.ml index 8e44c7da0..62eb7a9a6 100644 --- a/tools/depend.ml +++ b/tools/depend.ml @@ -109,7 +109,7 @@ let rec add_pattern bv pat = | Ppat_alias(p, _) -> add_pattern bv p | Ppat_constant _ -> () | Ppat_tuple pl -> List.iter (add_pattern bv) pl - | Ppat_construct(c, op, _) -> add bv c; add_opt add_pattern bv op + | Ppat_construct(c, op, _, _) -> add bv c; add_opt add_pattern bv op | Ppat_record(pl, _) -> List.iter (fun (lbl, p) -> add bv lbl; add_pattern bv p) pl | Ppat_array pl -> List.iter (add_pattern bv) pl diff --git a/typing/parmatch.ml b/typing/parmatch.ml index 21d498cd0..69cd51733 100644 --- a/typing/parmatch.ml +++ b/typing/parmatch.ml @@ -1850,10 +1850,12 @@ let generate_all (env:Env.t) : pattern -> pattern list = begin match decl.type_kind with | Type_generalized_variant constr_list -> let lid_of_tyres = - match ty_res.desc with + match (Ctype.repr ty_res).desc with (* GAH : ask garrigue, without this repr it will not work *) | Tconstr(p,_,_) -> Ctype.lid_of_path "" p - | _ -> assert false + | _ -> + Format.printf "%a@." Printtyp.raw_type_expr ty_res; + assert false in let constrs = filter_map (make_constr ty_res lid_of_tyres lid) constr_list in let constrs = uniquefy type_equivalence constrs in |