text stringlengths 0 601k |
|---|
let merge_errors ~ global_resolution errors = errors |> List . map ~ f ( : fun ( { Error . kind ; _ } as error ) -> { error with kind = Error . weaken_literals kind } ) |> Error . join_at_source ~ resolution : global_resolution |> List . sort ~ compare : Error . compare |
let legacy_infer_for_define ~ configuration ~ global_resolution ~ source ( { : Source . source_path = { ModulePath . qualifier ; relative ; _ } ; _ } as source ) ~ define ( { : Node . location ; value = { Define . signature = { name ; _ } ; _ } } as define ) = try let local_errors = infer_local ~ configuration ~ global... |
let infer_for_define ~ configuration ~ global_resolution ~ source ~ qualifier ~ filename_lookup ~ define = let timer = Timer . start ( ) in let { Node . location ; value = { Define . signature ; _ } } = define in let abstract = Define . Signature . is_abstract_method signature in let error_to_inference { AnalysisError ... |
let should_analyze_define ~ skip_annotated ~ global_resolution { Node . value = { Define . signature = { return_annotation ; parameters ; _ } ; _ } as define ; _ } = let alias_environment = GlobalResolution . alias_environment global_resolution in let is_missing_or_invalid maybe_expression = let resolve_type expression... |
let empty_infer_for_define ~ global_resolution ~ qualifier ~ define = let lookup _ = None in TypeInferenceData . LocalResult . from_signature ~ global_resolution ~ lookup ~ qualifier define |
let infer_for_module ( ? skip_annotated = true ) ~ configuration ~ global_resolution ~ filename_lookup ( { Ast . Source . source_path = { qualifier ; _ } as source_path ; _ } as source ) = Log . debug " Running infer for % s . . . " source_path . relative ; let check define = if should_analyze_define ~ skip_annotated ~... |
module Testing = struct let define_names_to_analyze ~ global_resolution source = source |> Preprocessing . defines ~ include_toplevels : true |> List . filter ~ f ( : should_analyze_define ~ skip_annotated : true ~ global_resolution ) |> List . map ~ f ( : fun define -> define |> Node . value |> Define . name ) end |
let configuration = Configuration . Analysis . create ~ source_paths [ ] : ( ) |
let assert_backward ~ resolution precondition statement postcondition = let module State = State ( struct let qualifier = Reference . empty let configuration = configuration let define = + mock_define let resolution_fixpoint = Some ( LocalAnnotationMap . empty ( ) ) let error_map = Some ( TypeCheck . LocalErrorMap . em... |
let test_backward_resolution_handling context = let resolution = ScratchProject . setup ~ context [ ] |> ScratchProject . build_resolution in let assert_backward = assert_backward ~ resolution in assert_backward [ " y " , Type . integer ] " pass " [ " y " , Type . integer ] ; assert_backward [ " x " , Type . integer ] ... |
let test_inferred_function_parameters context = let check_inference_results = check_inference_results ~ field_path [ " : define " ; " parameters " ] ~ context in let single_parameter ( ? name = " x " ) ? default type_ = Format . asprintf { | [ { " name " : " % s " , " annotation " : " % s " , " value " : % s , " index ... |
let test_inferred_method_parameters context = let check_inference_results = check_inference_results ~ context ~ field_path [ " : define " ; " parameters " ] in let single_parameter_method type_ = Format . asprintf { | [ { " name " : " self " , " annotation " : null , " value " : null , " index " : 0 } , { " name " : " ... |
let test_inferred_globals context = let check_inference_results = check_inference_results ~ context ~ field_path [ " : globals " ] in check_inference_results { | def foo ( ) -> int : return 1234 x = foo ( ) } | ~ target " : test . $ toplevel " ~ expected : { | [ { " name " : " x " , " location " : { " qualifier " : " t... |
let test_inferred_attributes context = let check_inference_results = check_inference_results ~ context ~ field_path [ " : attributes " ] in check_inference_results { | def foo ( ) -> int : return 1 class Foo : x = foo ( ) } | ~ target " : test . Foo . $ class_toplevel " ~ expected : { | [ { " parent " : " test . Foo " ... |
let ( ) = " typeInferenceLocalTest " >::: [ " test_backward_resolution_handling " >:: test_backward_resolution_handling ; " test_should_analyze_define " >:: test_should_analyze_define ; " test_inferred_returns " >:: test_inferred_returns ; " test_inferred_function_parameters " >:: test_inferred_function_parameters ; " ... |
type conversion_function = JavaAST . expression -> JavaAST . expression |
type t = { ocaml_type : Path . t option ; java_type : JavaAST . type_ ; java_of_ocaml : conversion_function ; ocaml_of_java : conversion_function ; } |
let make_simple ident = let path = Path . Pident ident in let name = Ident . name ident in let info = { ocaml_type = Some path ; java_type = JavaAST . Reference ( name , [ ] ) ; java_of_ocaml = ( fun e -> JavaAST . Static_call ( name , " wrap " , [ e ] e ) e ) e ; ocaml_of_java = ( fun e -> JavaAST . Call ( e , " value... |
let type_int = { ocaml_type = Some Predef . path_int ; java_type = JavaAST . Long ; java_of_ocaml = ( fun e -> JavaAST . Call ( e , " asLong " , [ ] ) ) ; ocaml_of_java = ( fun e -> JavaAST . Static_call ( " Value " , " createLong " , [ e ] e ) e ) e ; } |
let type_int_boxed = { ocaml_type = Some Predef . path_int ; java_type = JavaAST . Reference ( " OCamlInt " , [ ] ) ; java_of_ocaml = ( fun e -> JavaAST . Static_call ( " OCamlInt " , " wrap " , [ e ] e ) e ) e ; ocaml_of_java = ( fun e -> JavaAST . Call ( e , " value " , [ ] ) ) ; } |
let type_char = { ocaml_type = Some Predef . path_char ; java_type = JavaAST . Int ; java_of_ocaml = ( fun e -> JavaAST . Call ( e , " asCastedInt " , [ ] ) ) ; ocaml_of_java = ( fun e -> JavaAST . Static_call ( " Value " , " createLong " , [ e ] e ) e ) e ; } |
let type_char_boxed = { ocaml_type = Some Predef . path_char ; java_type = JavaAST . Reference ( " OCamlChar " , [ ] ) ; java_of_ocaml = ( fun e -> JavaAST . Static_call ( " OCamlChar " , " wrap " , [ e ] e ) e ) e ; ocaml_of_java = ( fun e -> JavaAST . Call ( e , " value " , [ ] ) ) ; } |
let type_string = { ocaml_type = Some Predef . path_string ; java_type = JavaAST . Reference ( " String " , [ ] ) ; java_of_ocaml = ( fun e -> JavaAST . Call ( e , " asString " , [ ] ) ) ; ocaml_of_java = ( fun e -> JavaAST . Static_call ( " Value " , " createString " , [ e ] e ) e ) e ; } |
let type_string_boxed = { ocaml_type = Some Predef . path_string ; java_type = JavaAST . Reference ( " OCamlString " , [ ] ) ; java_of_ocaml = ( fun e -> JavaAST . Static_call ( " OCamlString " , " wrap " , [ e ] e ) e ) e ; ocaml_of_java = ( fun e -> JavaAST . Call ( e , " value " , [ ] ) ) ; } |
let type_byte_array = { ocaml_type = Some Predef . path_string ; java_type = JavaAST . Array JavaAST . Byte ; java_of_ocaml = ( fun e -> JavaAST . Call ( e , " getBytesForModification " , [ ] ) ) ; ocaml_of_java = ( fun e -> JavaAST . Static_call ( " Value " , " createString " , [ e ] e ) e ) e ; } |
let type_float = { ocaml_type = Some Predef . path_float ; java_type = JavaAST . Double ; java_of_ocaml = ( fun e -> JavaAST . Call ( e , " asDouble " , [ ] ) ) ; ocaml_of_java = ( fun e -> JavaAST . Static_call ( " Value " , " createDouble " , [ e ] e ) e ) e ; } |
let type_float_boxed = { ocaml_type = Some Predef . path_float ; java_type = JavaAST . Reference ( " OCamlFloat " , [ ] ) ; java_of_ocaml = ( fun e -> JavaAST . Static_call ( " OCamlFloat " , " wrap " , [ e ] e ) e ) e ; ocaml_of_java = ( fun e -> JavaAST . Call ( e , " value " , [ ] ) ) ; } |
let type_bool = { ocaml_type = Some Predef . path_bool ; java_type = JavaAST . Boolean ; java_of_ocaml = ( fun e -> JavaAST . Static_call ( " OCamlWrappers " , " asBool " , [ e ] e ) e ) e ; ocaml_of_java = ( fun e -> JavaAST . Static_call ( " OCamlWrappers " , " createBool " , [ e ] e ) e ) e ; } |
let type_bool_boxed = { ocaml_type = Some Predef . path_bool ; java_type = JavaAST . Reference ( " OCamlBool " , [ ] ) ; java_of_ocaml = ( fun e -> JavaAST . Static_call ( " OCamlBool " , " wrap " , [ e ] e ) e ) e ; ocaml_of_java = ( fun e -> JavaAST . Call ( e , " value " , [ ] ) ) ; } |
let type_unit_boxed = { ocaml_type = Some Predef . path_unit ; java_type = JavaAST . Reference ( " OCamlUnit " , [ ] ) ; java_of_ocaml = ( fun e -> JavaAST . Static_call ( " OCamlUnit " , " wrap " , [ e ] e ) e ) e ; ocaml_of_java = ( fun e -> JavaAST . Call ( e , " value " , [ ] ) ) ; } |
let type_nativeint = { ocaml_type = Some Predef . path_nativeint ; java_type = JavaAST . Long ; java_of_ocaml = ( fun e -> JavaAST . Call ( e , " asNativeInt " , [ ] ) ) ; ocaml_of_java = ( fun e -> JavaAST . Static_call ( " Value " , " createNativeInt " , [ e ] e ) e ) e ; } |
let type_nativeint_boxed = { ocaml_type = Some Predef . path_nativeint ; java_type = JavaAST . Reference ( " OCamlNativeInt " , [ ] ) ; java_of_ocaml = ( fun e -> JavaAST . Static_call ( " OCamlNativeInt " , " wrap " , [ e ] e ) e ) e ; ocaml_of_java = ( fun e -> JavaAST . Call ( e , " value " , [ ] ) ) ; } |
let type_int32 = { ocaml_type = Some Predef . path_int32 ; java_type = JavaAST . Int ; java_of_ocaml = ( fun e -> JavaAST . Call ( e , " asInt32 " , [ ] ) ) ; ocaml_of_java = ( fun e -> JavaAST . Static_call ( " Value " , " createInt32 " , [ e ] e ) e ) e ; } |
let type_int32_boxed = { ocaml_type = Some Predef . path_int32 ; java_type = JavaAST . Reference ( " OCamlInt32 " , [ ] ) ; java_of_ocaml = ( fun e -> JavaAST . Static_call ( " OCamlInt32 " , " wrap " , [ e ] e ) e ) e ; ocaml_of_java = ( fun e -> JavaAST . Call ( e , " value " , [ ] ) ) ; } |
let type_int64 = { ocaml_type = Some Predef . path_int64 ; java_type = JavaAST . Long ; java_of_ocaml = ( fun e -> JavaAST . Call ( e , " asInt64 " , [ ] ) ) ; ocaml_of_java = ( fun e -> JavaAST . Static_call ( " Value " , " createInt64 " , [ e ] e ) e ) e ; } |
let type_int64_boxed = { ocaml_type = Some Predef . path_int64 ; java_type = JavaAST . Reference ( " OCamlInt64 " , [ ] ) ; java_of_ocaml = ( fun e -> JavaAST . Static_call ( " OCamlInt64 " , " wrap " , [ e ] e ) e ) e ; ocaml_of_java = ( fun e -> JavaAST . Call ( e , " value " , [ ] ) ) ; } |
let type_array = { ocaml_type = Some Predef . path_array ; java_type = JavaAST . Reference ( " OCamlArray " , [ ] ) ; java_of_ocaml = ( fun e -> JavaAST . Static_call ( " OCamlArray " , " wrap " , [ e ] e ) e ) e ; ocaml_of_java = ( fun e -> JavaAST . Call ( e , " value " , [ ] ) ) ; } |
let type_list = { ocaml_type = Some Predef . path_list ; java_type = JavaAST . Reference ( " OCamlList " , [ ] ) ; java_of_ocaml = ( fun e -> JavaAST . Static_call ( " OCamlList " , " wrap " , [ e ] e ) e ) e ; ocaml_of_java = ( fun e -> JavaAST . Call ( e , " value " , [ ] ) ) ; } |
let type_option = { ocaml_type = Some Predef . path_option ; java_type = JavaAST . Reference ( " OCamlOption " , [ ] ) ; java_of_ocaml = ( fun e -> JavaAST . Static_call ( " OCamlOption " , " wrap " , [ e ] e ) e ) e ; ocaml_of_java = ( fun e -> JavaAST . Call ( e , " value " , [ ] ) ) ; } |
let type_lazy = { ocaml_type = Some Predef . path_lazy_t ; java_type = JavaAST . Reference ( " OCamlLazy " , [ ] ) ; java_of_ocaml = ( fun e -> JavaAST . Static_call ( " OCamlLazy " , " wrap " , [ e ] e ) e ) e ; ocaml_of_java = ( fun e -> JavaAST . Call ( e , " value " , [ ] ) ) ; } |
let type_ref = let path_pervasives = Path . Pident ( Ident . create_persistent " Pervasives ) " in let path = Path . Pdot ( path_pervasives , " ref " , 0 ) 0 in { ocaml_type = Some path ; java_type = JavaAST . Reference ( " OCamlRef " , [ ] ) ; java_of_ocaml = ( fun e -> JavaAST . Static_call ( " OCamlRef " , " wrap " ... |
let type_in_channel = let path_pervasives = Path . Pident ( Ident . create_persistent " Pervasives ) " in let path = Path . Pdot ( path_pervasives , " in_channel " , 0 ) 0 in { ocaml_type = Some path ; java_type = JavaAST . Reference ( " OCamlInChannel " , [ ] ) ; java_of_ocaml = ( fun e -> JavaAST . Static_call ( " OC... |
let type_out_channel = let path_pervasives = Path . Pident ( Ident . create_persistent " Pervasives ) " in let path = Path . Pdot ( path_pervasives , " out_channel " , 0 ) 0 in { ocaml_type = Some path ; java_type = JavaAST . Reference ( " OCamlOutChannel " , [ ] ) ; java_of_ocaml = ( fun e -> JavaAST . Static_call ( "... |
let type_exn = { ocaml_type = Some Predef . path_exn ; java_type = JavaAST . Reference ( " OCamlExn " , [ ] ) ; java_of_ocaml = ( fun e -> JavaAST . Static_call ( " OCamlExn " , " wrap " , [ e ] e ) e ) e ; ocaml_of_java = ( fun e -> JavaAST . Call ( e , " value " , [ ] ) ) ; } |
let always_predefined_types = [ type_array ; type_list ; type_option ; type_lazy ; type_ref ; type_in_channel ; type_out_channel ; type_exn ; ] |
let boxed_only_predefined_types = [ type_int_boxed ; type_char_boxed ; type_float_boxed ; type_bool_boxed ; type_unit_boxed ; type_nativeint_boxed ; type_int32_boxed ; type_int64_boxed ; ] |
let unboxed_only_predefined_types = [ type_int ; type_char ; type_float ; type_bool ; type_nativeint ; type_int32 ; type_int64 ; ] |
let boxed_predefined_types = type_string_boxed :: ( boxed_only_predefined_types @ always_predefined_types ) always_predefined_types |
let unboxed_predefined_types = ref None |
let predefined_types boxed = if boxed then boxed_predefined_types else begin match ! unboxed_predefined_types with | Some cache -> cache | None -> let res = ( match ! Args . string_mapping with | Args . Java_string -> type_string | Args . OCamlString -> type_string_boxed | Args . Byte_array -> type_byte_array ) type_by... |
module HashedPath = struct type t = Path . t let equal x y = Path . same x y let rec hash = function | Path . Pident id -> Hashtbl . hash ( Ident . name id ) id | Path . Pdot ( p , s , _ ) _ -> ( hash p ) p + ( Hashtbl . hash s ) s | Path . Papply ( p1 , p2 ) p2 -> ( hash p1 ) p1 + ( hash p2 ) p2 end |
module Definitions = Hashtbl . Make ( HashedPath ) HashedPath |
type definitions = ( TypeInfo . t * bool ) bool Definitions . t |
let defined : definitions = Definitions . create 17 |
let locally_defined : definitions = Definitions . create 17 |
let is_defined_and_doesnt_expand path = try snd ( Definitions . find defined path ) path with Not_found -> try snd ( Definitions . find locally_defined path ) path with _ -> false |
let add_local ident dont_expand = let path , info = TypeInfo . make_simple ident in Definitions . add locally_defined path ( info , dont_expand ) dont_expand |
let promote modname = let modpath = Path . Pident ( Ident . create_persistent modname ) modname in Definitions . iter ( fun path ( info , dont_expand ) dont_expand -> let otyp = Path . Pdot ( modpath , Path . name path , 0 ) 0 in let jtyp , name = match info . TypeInfo . java_type with | JavaAST . Reference ( cn , l ) ... |
let find_predefined boxed path = List . find ( fun x -> match x . TypeInfo . ocaml_type with | Some p -> Path . same p path | None -> false ) false ( TypeInfo . predefined_types boxed ) boxed |
let find_defined path = try try fst ( Definitions . find defined path ) path with Not_found -> fst ( Definitions . find locally_defined path ) path with Not_found -> ( match path with | Path . Pident id -> snd ( TypeInfo . make_simple id ) id | _ -> raise Not_found ) Not_found |
let find_from_constructor boxed path = try find_predefined boxed path with Not_found -> find_defined path |
let rec make_wrapper generics i = match i with | JavaAST . Reference ( cn , l ) l -> if TypeParametersTable . mem cn generics then begin match TypeParametersTable . find cn generics with | TypeParametersTable . Parameter path -> let path = List . rev path in begin match path with | param :: accesses -> let base = JavaA... |
let augment_with_type_parameters generics res l = let l ' ' = List . map ( fun x -> x . TypeInfo . java_type ) java_type l in let jt = match res . TypeInfo . java_type with | JavaAST . Reference ( cn , [ ] ) -> JavaAST . Reference ( cn , l ' ' ) l ' ' | _ -> assert false in let joo e = let l = List . map ( fun i -> mak... |
let rec string_of_type_expr te = string_of_type_desc te . Types . desc let open Types in match td with | Tvar None -> " ' " ? | Tvar ( Some s ) s -> " ' " ^ s | Tarrow ( _ , te1 , te2 , _ ) _ -> ( string_of_type_expr te1 ) te1 ^ " -> " ^ ( string_of_type_expr te2 ) te2 | Ttuple l -> string_of_type_expr_list l | Tconstr... |
let rec find ( ? generics = TypeParametersTable . empty ) empty boxed t = let open Types in match t . desc with | Tlink t ' -> find ~ generics boxed t ' | Tobject ( _ , { contents = Some ( path , l ) l } ) | Tconstr ( path , l , _ ) _ when is_defined_and_doesnt_expand path -> let res = find_defined path in let l = List... |
let find ( ? generics = TypeParametersTable . empty ) empty boxed t = try find ~ generics boxed t with Not_found -> Wrap_common ( . fail ( Cannot_find_type ( string_of_type_expr t ) t ) t ) t |
module Sig_component_kind = struct type t = | Value | Type | Module | Module_type | Extension_constructor | Class | Class_type let to_string = function | Value -> " value " | Type -> " type " | Module -> " module " | Module_type -> " module type " | Extension_constructor -> " extension constructor " | Class -> " class ... |
type hiding_error = | Illegal_shadowing of { shadowed_item_id : Ident . t ; shadowed_item_kind : Sig_component_kind . t ; shadowed_item_loc : Location . t ; shadower_id : Ident . t ; user_id : Ident . t ; user_kind : Sig_component_kind . t ; user_loc : Location . t ; } | Appears_in_signature of { opened_item_id : Ident... |
type error = Cannot_apply of module_type | Not_included of Includemod . error list | Cannot_eliminate_dependency of module_type | Signature_expected | Structure_expected of module_type | With_no_component of Longident . t | With_mismatch of Longident . t * Includemod . error list | With_makes_applicative_functor_ill_ty... |
let rec path_concat head p = match p with Pident tail -> Pdot ( Pident head , Ident . name tail ) | Pdot ( pre , s ) -> Pdot ( path_concat head pre , s ) | Papply _ -> assert false |
let extract_sig env loc mty = match Env . scrape_alias env mty with Mty_signature sg -> sg | Mty_alias path -> raise ( Error ( loc , env , Cannot_scrape_alias path ) ) | _ -> raise ( Error ( loc , env , Signature_expected ) ) |
let extract_sig_open env loc mty = match Env . scrape_alias env mty with Mty_signature sg -> sg | Mty_alias path -> raise ( Error ( loc , env , Cannot_scrape_alias path ) ) | mty -> raise ( Error ( loc , env , Structure_expected mty ) ) |
let type_open_ ? used_slot ? toplevel ovf env loc lid = let path = Env . lookup_module_path ~ load : true ~ loc : lid . loc lid . txt env in match Env . open_signature ~ loc ? used_slot ? toplevel ovf path env with | Some env -> path , env | None -> let md = Env . find_module path env in ignore ( extract_sig_open env l... |
let initial_env ~ loc ~ safe_string ~ initially_opened_module ~ open_implicit_modules = let env = if safe_string then Env . initial_safe_string else Env . initial_unsafe_string in let open_module env m = let open Asttypes in let lid = { loc ; txt = Longident . parse m } in snd ( type_open_ Override env lid . loc lid ) ... |
let type_open_descr ? used_slot ? toplevel env sod = let ( path , newenv ) = Builtin_attributes . warning_scope sod . popen_attributes ( fun ( ) -> type_open_ ? used_slot ? toplevel sod . popen_override env sod . popen_loc sod . popen_expr ) in let od = { open_expr = ( path , sod . popen_expr ) ; open_bound_items = [ ]... |
let rm node = Stypes . record ( Stypes . Ti_mod node ) ; node |
let type_module_type_of_fwd : ( Env . t -> Parsetree . module_expr -> Typedtree . module_expr * Types . module_type ) ref = ref ( fun _env _m -> assert false ) |
let check_recmod_typedecls env decls = let recmod_ids = List . map fst decls in List . iter ( fun ( id , md ) -> List . iter ( fun path -> Typedecl . check_recmod_typedecl env md . Types . md_loc recmod_ids path ( Env . find_type path env ) ) ( Mtype . type_paths env ( Pident id ) md . Types . md_type ) ) decls |
let rec add_rec_types env = function Sig_type ( id , decl , Trec_next , _ ) :: rem -> add_rec_types ( Env . add_type ~ check : true id decl env ) rem | _ -> env |
let check_type_decl env loc id row_id newdecl decl rs rem = let env = Env . add_type ~ check : true id newdecl env in let env = match row_id with | None -> env | Some id -> Env . add_type ~ check : false id newdecl env in let env = if rs = Trec_not then env else add_rec_types env rem in Includemod . type_declarations ~... |
let update_rec_next rs rem = match rs with Trec_next -> rem | Trec_first | Trec_not -> match rem with Sig_type ( id , decl , Trec_next , priv ) :: rem -> Sig_type ( id , decl , rs , priv ) :: rem | Sig_module ( id , pres , mty , Trec_next , priv ) :: rem -> Sig_module ( id , pres , mty , rs , priv ) :: rem | _ -> rem |
let make_variance p n i = let open Variance in set May_pos p ( set May_neg n ( set May_weak n ( set Inj i null ) ) ) |
let rec iter_path_apply p ~ f = match p with | Pident _ -> ( ) | Pdot ( p , _ ) -> iter_path_apply p ~ f | Papply ( p1 , p2 ) -> iter_path_apply p1 ~ f ; iter_path_apply p2 ~ f ; f p1 p2 |
let path_is_strict_prefix = let rec list_is_strict_prefix l ~ prefix = match l , prefix with | [ ] , [ ] -> false | _ :: _ , [ ] -> true | [ ] , _ :: _ -> false | s1 :: t1 , s2 :: t2 -> String . equal s1 s2 && list_is_strict_prefix t1 ~ prefix : t2 in fun path ~ prefix -> match Path . flatten path , Path . flatten pref... |
let iterator_with_env env = let env = ref ( lazy env ) in let super = Btype . type_iterators in env , { super with Btype . it_signature = ( fun self sg -> let env_before = ! env in env := lazy ( Env . add_signature sg ( Lazy . force env_before ) ) ; super . Btype . it_signature self sg ; env := env_before ) ; Btype . i... |
let retype_applicative_functor_type ~ loc env funct arg = let mty_functor = ( Env . find_module funct env ) . md_type in let mty_arg = ( Env . find_module arg env ) . md_type in let mty_param = match Env . scrape_alias env mty_functor with | Mty_functor ( Named ( _ , mty_param ) , _ ) -> mty_param | _ -> assert false i... |
let check_usage_of_path_of_substituted_item paths env signature ~ loc ~ lid = let iterator = let env , super = iterator_with_env env in { super with Btype . it_signature_item = ( fun self -> function | Sig_module ( id , _ , { md_type = Mty_alias aliased_path ; _ } , _ , _ ) when List . exists ( fun path -> path_is_stri... |
let rec extract_next_modules = function | Sig_module ( id , _ , mty , Trec_next , _ ) :: rem -> let ( id_mty_l , rem ) = extract_next_modules rem in ( ( id , mty ) :: id_mty_l , rem ) | sg -> ( [ ] , sg ) |
let check_well_formed_module env loc context mty = let open Btype in let iterator = let rec check_signature env = function | [ ] -> ( ) | Sig_module ( id , _ , mty , Trec_first , _ ) :: rem -> let ( id_mty_l , rem ) = extract_next_modules rem in begin try check_recmod_typedecls ( Lazy . force env ) ( ( id , mty ) :: id... |
let ( ) = Env . check_well_formed_module := check_well_formed_module |
let type_decl_is_alias sdecl = match sdecl . ptype_manifest with | Some { ptyp_desc = Ptyp_constr ( lid , stl ) } when List . length stl = List . length sdecl . ptype_params -> begin match List . iter2 ( fun x ( y , _ ) -> match x , y with { ptyp_desc = Ptyp_var sx } , { ptyp_desc = Ptyp_var sy } when sx = sy -> ( ) | ... |
let params_are_constrained = let rec loop = function | [ ] -> false | hd :: tl -> match ( Btype . repr hd ) . desc with | Tvar _ -> List . memq hd tl || loop tl | _ -> true in loop ; ; |
let merge_constraint initial_env remove_aliases loc sg constr = let lid = match constr with | Pwith_type ( lid , _ ) | Pwith_module ( lid , _ ) | Pwith_typesubst ( lid , _ ) | Pwith_modsubst ( lid , _ ) -> lid in let destructive_substitution = match constr with | Pwith_type _ | Pwith_module _ -> false | Pwith_typesubst... |
let map_rec fn decls rem = match decls with | [ ] -> rem | d1 :: dl -> fn Trec_first d1 :: map_end ( fn Trec_next ) dl rem |
let map_rec_type ~ rec_flag fn decls rem = match decls with | [ ] -> rem | d1 :: dl -> let first = match rec_flag with | Recursive -> Trec_first | Nonrecursive -> Trec_not in fn first d1 :: map_end ( fn Trec_next ) dl rem |
let rec map_rec_type_with_row_types ~ rec_flag fn decls rem = match decls with | [ ] -> rem | d1 :: dl -> if Btype . is_row_name ( Ident . name d1 . typ_id ) then fn Trec_not d1 :: map_rec_type_with_row_types ~ rec_flag fn dl rem else map_rec_type ~ rec_flag fn decls rem |
let map_ext fn exts rem = match exts with | [ ] -> rem | d1 :: dl -> fn Text_first d1 :: map_end ( fn Text_next ) dl rem |
let rec approx_modtype env smty = match smty . pmty_desc with Pmty_ident lid -> let ( path , _info ) = Env . lookup_modtype ~ use : false ~ loc : smty . pmty_loc lid . txt env in Mty_ident path | Pmty_alias lid -> let path = Env . lookup_module_path ~ use : false ~ load : false ~ loc : smty . pmty_loc lid . txt env in ... |
let approx_modtype env smty = Warnings . without_warnings ( fun ( ) -> approx_modtype env smty ) |
module Signature_names : sig type t type info = [ | ` Exported | ` From_open | ` Shadowable of Ident . t * Location . t | ` Substituted_away of Subst . t ] val create : unit -> t val check_value : ? info : info -> t -> Location . t -> Ident . t -> unit val check_type : ? info : info -> t -> Location . t -> Ident . t ->... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.