jon.recoil.org

Module Ocaml_typing.Env

type value_unbound_reason =
  1. | Val_unbound_instance_variable
  2. | Val_unbound_self
  3. | Val_unbound_ancestor
  4. | Val_unbound_ghost_recursive of Ocaml_parsing.Location.t
type module_unbound_reason =
  1. | Mod_unbound_illegal_recursion of {
    1. container : string option;
    2. unbound : string;
    }
type locks
type summary =
  1. | Env_empty
  2. | Env_value of Ocaml_typing.Env.summary * Ocaml_typing.Ident.t * Ocaml_typing.Types.value_description * Ocaml_typing.Mode.Value.l
  3. | Env_type of Ocaml_typing.Env.summary * Ocaml_typing.Ident.t * Ocaml_typing.Types.type_declaration
  4. | Env_extension of Ocaml_typing.Env.summary * Ocaml_typing.Ident.t * Ocaml_typing.Types.extension_constructor
  5. | Env_module of Ocaml_typing.Env.summary * Ocaml_typing.Ident.t * Ocaml_typing.Types.module_presence * Ocaml_typing.Types.module_declaration * Ocaml_typing.Mode.Value.l * Ocaml_typing.Env.locks
  6. | Env_modtype of Ocaml_typing.Env.summary * Ocaml_typing.Ident.t * Ocaml_typing.Types.modtype_declaration
  7. | Env_class of Ocaml_typing.Env.summary * Ocaml_typing.Ident.t * Ocaml_typing.Types.class_declaration
  8. | Env_cltype of Ocaml_typing.Env.summary * Ocaml_typing.Ident.t * Ocaml_typing.Types.class_type_declaration
  9. | Env_open of Ocaml_typing.Env.summary * Ocaml_typing.Path.t
    (*

    The string set argument of Env_open represents a list of module names to skip, i.e. that won't be imported in the toplevel namespace.

    *)
  10. | Env_functor_arg of Ocaml_typing.Env.summary * Ocaml_typing.Ident.t
  11. | Env_constraints of Ocaml_typing.Env.summary * Ocaml_typing.Types.type_declaration Ocaml_typing.Path.Map.t
  12. | Env_copy_types of Ocaml_typing.Env.summary
  13. | Env_persistent of Ocaml_typing.Env.summary * Ocaml_typing.Ident.t
  14. | Env_value_unbound of Ocaml_typing.Env.summary * string * Ocaml_typing.Env.value_unbound_reason
  15. | Env_module_unbound of Ocaml_typing.Env.summary * string * Ocaml_typing.Env.module_unbound_reason
type t
type stage
val empty : Ocaml_typing.Env.t
val same_type_declarations : Ocaml_typing.Env.t -> Ocaml_typing.Env.t -> bool
type type_descriptions = Ocaml_typing.Env.type_descr_kind
type iter_cont
val same_types : Ocaml_typing.Env.t -> Ocaml_typing.Env.t -> bool
val used_persistent : unit -> Ocaml_typing.Compilation_unit.Name.Set.t
val find_shadowed_types : Ocaml_typing.Path.t -> Ocaml_typing.Env.t -> Ocaml_typing.Path.t list
val without_cmis : ('a -> 'b) -> 'a -> 'b

Find a value by an Ident.t. Raises if encounters any locks.

val shape_for_constr : Ocaml_typing.Env.t -> Ocaml_typing.Path.t -> args:Ocaml_typing.Shape.t list -> Ocaml_typing.Shape.t option
val is_functor_arg : Ocaml_typing.Path.t -> Ocaml_typing.Env.t -> bool
val normalize_instance_names_in_module_path : Ocaml_typing.Path.t -> Ocaml_typing.Path.t
val reset_required_globals : unit -> unit
val get_required_globals : unit -> Ocaml_typing.Compilation_unit.t list
val add_required_global : Ocaml_typing.Path.t -> Ocaml_typing.Env.t -> unit
val reset_probes : unit -> unit
val add_probe : string -> unit
val has_probe : string -> bool
val has_local_constraints : Ocaml_typing.Env.t -> bool
val mark_value_used : Ocaml_typing.Types.Uid.t -> unit
val mark_module_used : Ocaml_typing.Types.Uid.t -> unit
val mark_type_used : Ocaml_typing.Types.Uid.t -> unit
val mark_value_mutated : Ocaml_typing.Types.Uid.t -> unit
type constructor_usage =
  1. | Positive
  2. | Pattern
  3. | Exported_private
  4. | Exported
val mark_constructor_used : Ocaml_typing.Env.constructor_usage -> Ocaml_typing.Types.Uid.t -> unit
type label_usage =
  1. | Projection
  2. | Mutation
  3. | Construct
  4. | Exported_private
  5. | Exported
type unbound_value_hint =
  1. | No_hint
  2. | Missing_rec of Ocaml_parsing.Location.t

Sometimes we get the locks for something, but either want to walk them later, or walk them for something else. The Longident.t and Location.t are only for error messages, and point to the variable for which we actually want to walk the locks.

val locks_empty : Ocaml_typing.Env.locks
val locks_is_empty : Ocaml_typing.Env.locks -> bool
type structure_components_reason =
  1. | Project
  2. | Open
type no_open_quotations_context =
  1. | Object_qt
  2. | Struct_qt
  3. | Sig_qt
  4. | Open_qt
type lookup_error =
  1. | Unbound_value of Ocaml_parsing.Longident.t * Ocaml_typing.Env.unbound_value_hint
  2. | Unbound_type of Ocaml_parsing.Longident.t
  3. | Unbound_constructor of Ocaml_parsing.Longident.t
  4. | Unbound_label of Ocaml_parsing.Longident.t * Ocaml_typing.Types.record_form_packed * Ocaml_typing.Env.label_usage
  5. | Unbound_module of Ocaml_parsing.Longident.t
  6. | Unbound_class of Ocaml_parsing.Longident.t
  7. | Unbound_modtype of Ocaml_parsing.Longident.t
  8. | Unbound_cltype of Ocaml_parsing.Longident.t
  9. | Unbound_settable_variable of string
  10. | Not_a_settable_variable of string
  11. | Masked_instance_variable of Ocaml_parsing.Longident.t
  12. | Masked_self_variable of Ocaml_parsing.Longident.t
  13. | Masked_ancestor_variable of Ocaml_parsing.Longident.t
  14. | Structure_used_as_functor of Ocaml_parsing.Longident.t
  15. | Abstract_used_as_functor of Ocaml_parsing.Longident.t * Ocaml_typing.Path.t
  16. | Functor_used_as_structure of Ocaml_parsing.Longident.t * Ocaml_typing.Env.structure_components_reason
  17. | Abstract_used_as_structure of Ocaml_parsing.Longident.t * Ocaml_typing.Path.t * Ocaml_typing.Env.structure_components_reason
  18. | Generative_used_as_applicative of Ocaml_parsing.Longident.t
  19. | Illegal_reference_to_recursive_module of {
    1. container : string option;
    2. unbound : string;
    }
  20. | Illegal_reference_to_recursive_class_type of {
    1. container : string option;
    2. unbound : string;
    3. unbound_class_type : Ocaml_parsing.Longident.t;
    4. container_class_type : string;
    }
  21. | Cannot_scrape_alias of Ocaml_parsing.Longident.t * Ocaml_typing.Path.t
  22. | Local_value_used_in_exclave of Ocaml_typing.Mode.Hint.lock_item * Ocaml_parsing.Longident.t
  23. | Non_value_used_in_object of Ocaml_parsing.Longident.t * Ocaml_typing.Types.type_expr * Ocaml_typing.Jkind.Violation.t
  24. | No_unboxed_version of Ocaml_parsing.Longident.t * Ocaml_typing.Types.type_declaration
  25. | Error_from_persistent_env of Ocaml_typing.Persistent_env.error
  26. | Mutable_value_used_in_closure of Ocaml_typing.Mode.Hint.pinpoint
  27. | Incompatible_stage of Ocaml_parsing.Longident.t * Ocaml_parsing.Location.t * Ocaml_typing.Env.stage * Ocaml_parsing.Location.t * Ocaml_typing.Env.stage
  28. | No_constructor_in_stage of Ocaml_parsing.Longident.t * Ocaml_parsing.Location.t * int

Takes the mode and the type of a value at definition site, walks through the list of locks and constrains the mode and the type. Return the access mode of the value allowed by the locks. ty is optional as the function works on modules and classes as well, for which ty should be None.

val lookup_module_instance_path : ?use:bool -> loc:Ocaml_parsing.Location.t -> load:bool -> Ocaml_typing.Global_module.Name.t -> Ocaml_typing.Env.t -> Ocaml_typing.Path.t * Ocaml_typing.Env.locks
val lookup_all_labels_from_type : ?use:bool -> record_form:'rcd Ocaml_typing.Types.record_form -> loc:Ocaml_parsing.Location.t -> Ocaml_typing.Env.label_usage -> Ocaml_typing.Path.t -> Ocaml_typing.Env.t -> ('rcd Ocaml_typing.Types.gen_label_description * (unit -> unit)) list
val lookup_settable_variable : ?use:bool -> loc:Ocaml_parsing.Location.t -> string -> Ocaml_typing.Env.t -> Ocaml_typing.Env.settable_variable

For a mutable variable, use means mark as mutated. For an instance variable, it means mark as used.

val find_value_index : Ocaml_typing.Ident.t -> Ocaml_typing.Env.t -> int option

The find_*_index functions computes a "namespaced" De Bruijn index of an identifier in a given environment. In other words, it returns how many times an identifier has been shadowed by a more recent identifiers with the same name in a given environment. Those functions return None when the identifier is not bound in the environment. This behavior is there to facilitate the detection of inconsistent printing environment, but should disappear in the long term.

val find_type_index : Ocaml_typing.Ident.t -> Ocaml_typing.Env.t -> int option
val find_module_index : Ocaml_typing.Ident.t -> Ocaml_typing.Env.t -> int option
val find_modtype_index : Ocaml_typing.Ident.t -> Ocaml_typing.Env.t -> int option
val find_class_index : Ocaml_typing.Ident.t -> Ocaml_typing.Env.t -> int option
val find_cltype_index : Ocaml_typing.Ident.t -> Ocaml_typing.Env.t -> int option
val bound_value : string -> Ocaml_typing.Env.t -> bool
val bound_module : string -> Ocaml_typing.Env.t -> bool
val bound_type : string -> Ocaml_typing.Env.t -> bool
val bound_modtype : string -> Ocaml_typing.Env.t -> bool
val bound_class : string -> Ocaml_typing.Env.t -> bool
val bound_cltype : string -> Ocaml_typing.Env.t -> bool
val global_of_instance_compilation_unit : Ocaml_typing.Compilation_unit.t -> Ocaml_typing.Global_module.t
val add_persistent_structure : Ocaml_typing.Ident.t -> Ocaml_typing.Env.t -> Ocaml_typing.Env.t
val persistent_structures_of_dir : Ocaml_utils.Load_path.Dir.t -> Merlin_utils.Misc.String.Set.t
val persistent_structures_of_basenames : string list -> Merlin_utils.Misc.String.Set.t
val filter_non_loaded_persistent : (Ocaml_typing.Ident.t -> bool) -> Ocaml_typing.Env.t -> Ocaml_typing.Env.t
val open_signature_by_path : Ocaml_typing.Path.t -> Ocaml_typing.Env.t -> Ocaml_typing.Env.t
val remove_last_open : Ocaml_typing.Path.t -> Ocaml_typing.Env.t -> Ocaml_typing.Env.t option
val enter_extension : scope:int -> rebind:bool -> string -> Ocaml_typing.Types.extension_constructor -> Ocaml_typing.Env.t -> Ocaml_typing.Ident.t * Ocaml_typing.Env.t

A variant of add_closure_lock where the mode of the closure is a constant due to the nature of the pinpoint. As a result, the mode is not printed in error messages. ghost = true means the closure is not a value (such as a loop)

val add_region_lock : Ocaml_typing.Env.t -> Ocaml_typing.Env.t
val add_exclave_lock : Ocaml_typing.Env.t -> Ocaml_typing.Env.t
val add_unboxed_lock : Ocaml_typing.Env.t -> Ocaml_typing.Env.t
val enter_quotation : Ocaml_typing.Env.t -> Ocaml_typing.Env.t
val reset_cache : preserve_persistent_env:bool -> unit
val reset_cache_toplevel : unit -> unit
val set_unit_name : Ocaml_typing.Unit_info.t option -> unit
val get_unit_name : unit -> Ocaml_typing.Unit_info.t option
val register_parameter : Ocaml_typing.Global_module.Parameter_name.t -> unit
val imports : unit -> Ocaml_typing.Import_info.t list
val import_crcs : source:string -> Ocaml_typing.Import_info.t array -> unit
val require_global_for_quote : Ocaml_typing.Compilation_unit.Name.t -> unit
val quoted_globals : unit -> Ocaml_typing.Compilation_unit.Name.t list
val runtime_parameter_bindings : unit -> (Ocaml_typing.Global_module.t * Ocaml_typing.Ident.t) list
val is_bound_to_runtime_parameter : Ocaml_typing.Ident.t -> bool
val parameters : unit -> Ocaml_typing.Global_module.Parameter_name.t list
val is_imported_opaque : Ocaml_typing.Compilation_unit.Name.t -> bool
val register_import_as_opaque : Ocaml_typing.Compilation_unit.Name.t -> unit
val is_parameter_unit : Ocaml_typing.Global_module.Name.t -> bool
val is_imported_parameter : Ocaml_typing.Global_module.Name.t -> bool
val keep_only_summary : Ocaml_typing.Env.t -> Ocaml_typing.Env.t
val update_short_paths : Ocaml_typing.Env.t -> Ocaml_typing.Env.t
type error =
  1. | Missing_module of Ocaml_parsing.Location.t * Ocaml_typing.Path.t * Ocaml_typing.Path.t
  2. | Illegal_value_name of Ocaml_parsing.Location.t * string
  3. | Lookup_error of Ocaml_parsing.Location.t * Ocaml_typing.Env.t * Ocaml_typing.Env.lookup_error
  4. | Incomplete_instantiation of {
    1. unset_param : Ocaml_typing.Global_module.Parameter_name.t;
    }
  5. | Toplevel_splice of Ocaml_parsing.Location.t
  6. | Unsupported_inside_quotation of Ocaml_parsing.Location.t * Ocaml_typing.Env.no_open_quotations_context
exception Error of Ocaml_typing.Env.error
val report_error : level:int -> Stdlib.Format.formatter -> Ocaml_typing.Env.error -> unit
val in_signature : bool -> Ocaml_typing.Env.t -> Ocaml_typing.Env.t
val is_in_signature : Ocaml_typing.Env.t -> bool
val set_value_used_callback : Ocaml_typing.Subst.Lazy.value_description -> (unit -> unit) -> unit
val set_value_mutated_callback : Ocaml_typing.Subst.Lazy.value_description -> (unit -> unit) -> unit
val set_type_used_callback : Ocaml_typing.Types.type_declaration -> ((unit -> unit) -> unit) -> unit
val check_functor_application : (errors:bool -> loc:Ocaml_parsing.Location.t -> lid_whole_app:Ocaml_parsing.Longident.t -> f0_path:Ocaml_typing.Path.t -> args:(Ocaml_typing.Path.t * Ocaml_typing.Types.module_type) list -> arg_path:Ocaml_typing.Path.t -> arg_mty:Ocaml_typing.Types.module_type -> param_mty:Ocaml_typing.Types.module_type -> Ocaml_typing.Env.t -> unit) Stdlib.ref
val check_well_formed_module : (Ocaml_typing.Env.t -> Ocaml_parsing.Location.t -> string -> Ocaml_typing.Types.module_type -> unit) Stdlib.ref
val add_delayed_check_forward : ((unit -> unit) -> unit) Stdlib.ref

Folds

Folding over all identifiers (for analysis purpose)

val fold_types : (string -> Ocaml_typing.Path.t -> Ocaml_typing.Types.type_declaration -> 'a -> 'a) -> Ocaml_parsing.Longident.t option -> Ocaml_typing.Env.t -> 'a -> 'a
val fold_constructors : (Ocaml_typing.Types.constructor_description -> 'a -> 'a) -> Ocaml_parsing.Longident.t option -> Ocaml_typing.Env.t -> 'a -> 'a
val fold_modules : (string -> Ocaml_typing.Path.t -> Ocaml_typing.Subst.Lazy.module_declaration -> 'a -> 'a) -> Ocaml_parsing.Longident.t option -> Ocaml_typing.Env.t -> 'a -> 'a

Persistent structures are only traversed if they are already loaded.

val fold_modtypes : (string -> Ocaml_typing.Path.t -> Ocaml_typing.Subst.Lazy.modtype_declaration -> 'a -> 'a) -> Ocaml_parsing.Longident.t option -> Ocaml_typing.Env.t -> 'a -> 'a
val fold_classes : (string -> Ocaml_typing.Path.t -> Ocaml_typing.Types.class_declaration -> 'a -> 'a) -> Ocaml_parsing.Longident.t option -> Ocaml_typing.Env.t -> 'a -> 'a
val fold_cltypes : (string -> Ocaml_typing.Path.t -> Ocaml_typing.Types.class_type_declaration -> 'a -> 'a) -> Ocaml_parsing.Longident.t option -> Ocaml_typing.Env.t -> 'a -> 'a
val check_value_name : string -> Ocaml_parsing.Location.t -> unit

Utilities

val print_address : Stdlib.Format.formatter -> Ocaml_typing.Env.address -> unit
type address_head =
  1. | AHunit of Ocaml_typing.Compilation_unit.t
  2. | AHlocal of Ocaml_typing.Ident.t
val print_stage : Stdlib.Format.formatter -> Ocaml_typing.Env.stage -> unit
val unbound_class : Ocaml_typing.Path.t

merlin: manage internal state

val check_state_consistency : unit -> bool
val with_cmis : (unit -> 'a) -> 'a
val cleanup_functor_caches : stamp:int -> unit
val cleanup_usage_tables : stamp:int -> unit
val msupport_raise_error : (?ignore_unify:bool -> exn -> unit) Stdlib.ref

This value should be filled in with Msupport.raise_error. Env cannot use this function directly because Msupport depends on Env

type 'acc fold_all_labels_f = {
  1. fold_all_labels_f : 'rcd. 'rcd Ocaml_typing.Types.record_form -> 'rcd Ocaml_typing.Types.gen_label_description -> 'acc -> 'acc;
}
val fold_all_labels : 'a Ocaml_typing.Env.fold_all_labels_f -> Ocaml_parsing.Longident.t option -> Ocaml_typing.Env.t -> 'a -> 'a
val print_with_quote_promote : Stdlib.Format.formatter -> (string * Ocaml_typing.Env.stage * Ocaml_typing.Env.stage) -> unit