Hi, The goal of this cmt file is to reflect the AST as it is in the source file so that explains why the aliases are not meant to be resolved. You can perform an analysis on the tree and rewrite it while resolving aliases. A functor will let you write just the functions you need and do the pattern matching for you : typedtreeIter.ml. It is located in the "typing" directory of the OCaml sources. Esther Baruk On Tue, Dec 4, 2012 at 2:08 AM, yoann padioleau wrote: > Hi, > > I want to use the .cmt files generated by -bin-annot for some > dependency analysis. The > problem is that not all names are resolved, especially module aliases > and type aliases are not > resolved. For instance on this file: > > module X = Variant > open Nested_module > module Y = Nested > > let use_variant = function > | X.Constructor1 -> 1 > | _ -> 2 > > > I got this dump for the AST/CMT file: > { > str_items=[Tstr_module("X", (), Tmod_ident("Variant", ())); > Tstr_open("Nested_module", ()); > Tstr_module("Y", (), Tmod_ident("Nested_module.Nested", ())); > Tstr_value((), > [(Tpat_var("use_variant", ()), > Texp_function((), > [(Tpat_construct("X.Constructor1", (), (), [], false), > Texp_constant(())); (Tpat_any, Texp_constant(()))], > ()))])]; > str_type=(); str_final_env=(); } > > but I would really like an AST where all names are fully resolved, so > X.Constructor1 becomes > Variant.Constructor1. In the example above Nested_module.Nested is > resolved (so the open Nested_module > is handled), but not X.Constructor1. > > Same for types, with this file: > type list2 = int list > > type use_list2 = > | Constructor of list2 > > let f = function > | Constructor [] -> 1 > | _ -> 2 > > > I got this dump of the AST/CMT: > { > str_items=[Tstr_type( > [("list2", (), > {typ_params=[]; typ_type=(); typ_cstrs=[]; > typ_kind=Ttype_abstract; typ_private=(); > typ_manifest=Some(Ttyp_constr("list", (), > [Ttyp_constr("int", (), [])])); > typ_variance=[]; typ_loc=(); })]); > Tstr_type( > [("use_list2", (), > {typ_params=[]; typ_type=(); typ_cstrs=[]; > typ_kind=Ttype_variant( > [("Constructor", (), > [Ttyp_constr("list2", (), [])], ())]); > typ_private=(); typ_manifest=None; typ_variance=[]; > typ_loc=(); })]); > Tstr_value((), > [(Tpat_var("f", ()), > Texp_function((), > [(Tpat_construct("Constructor", (), (), > [Tpat_construct("[]", (), (), [], false)], false), > Texp_constant(())); (Tpat_any, Texp_constant(()))], > ()))])]; > str_type=(); str_final_env=(); } > > and when I ask the type of [], it says list2, but I would really like > the final type that is int list2. > > Should I use env.ml for resolving? > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >