text
stringlengths
12
786k
let report_type_expected_explanation expl ppf = let because expl_str = fprintf ppf " @ because it is in % s " expl_str in match expl with | If_conditional -> because " the condition of an if - statement " | If_no_else_branch -> because " the result of a conditional with no else branch " | While_lo...
let report_type_expected_explanation_opt expl ppf = match expl with | None -> ( ) | Some expl -> report_type_expected_explanation expl ppf
let report_unification_error ~ loc ? sub env trace ? type_expected_explanation txt1 txt2 = Location . error_of_printer ~ loc ? sub ( fun ppf ( ) -> Printtyp . report_unification_error ppf env trace ? type_expected_explanation txt1 txt2 ) ( )
let report_error ~ loc env = function | Constructor_arity_mismatch ( lid , expected , provided ) -> Location . errorf ~ loc " [ @ The constructor % a @ expects % i argument ( s ) , @ \ but is applied here to % i argument ( s ) ] " @ longident lid expected provided | Label_misma...
let report_error ~ loc env err = wrap_printing_env ~ error : true env ( fun ( ) -> report_error ~ loc env err )
let ( ) = Location . register_error_of_exn ( function | Error ( loc , env , err ) -> Some ( report_error ~ loc env err ) | Error_forward err -> Some err | _ -> None )
let ( ) = Persistent_env . add_delayed_check_forward := add_delayed_check ; Env . add_delayed_check_forward := add_delayed_check ; ( )
let type_expect ? in_function env e ty = type_expect ? in_function env e ty
let type_exp env e = type_exp env e
let type_argument env e t1 t2 = type_argument env e t1 t2
let x = function 0 . . . 1 . -> ( ) ^^^^^^^^ } ] |
let f = function None None -> 0 [ %% expect { | ^^^^^^^^^ but is applied here to 1 argument ( s ) } ] |
let x = None None [ %% expect { | ^^^^^^^^^ but is applied here to 1 argument ( s ) } ] |
type t = A of { x : int }
let f = function ( A ( x : _ ) ) -> 0 [ %% expect { |
type t = A of { x : int ; } ^^^^^ } ] |
let f = function Some ( exception Not_found ) -> 0 [ %% expect { | ^^^^^^^^^^^^^^^^^^^^^ } ] |
let f = function [ % ext ] -> 0 [ %% expect { | ^^^ } ] |
let rec f x = ( ( ) , ( ) : _ -> _ -> _ ) [ %% expect { | ^^^^^^^^^^^^^^^^^^^^^^^^ but an expression was expected of type ' c -> ' d -> ' e } ] |
let rec g x = ( ( ( ) , ( ) ) : _ -> _ :> _ ) [ %% expect { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ but an expression was expected of type ' c -> ' d } ] |
let f x = match x with exception Not_found -> ( ) ; ; [ %% expect { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ } ] |
type r = { x : int }
let r = { x = 1 ; x = 1 } [ %% expect { |
type r = { x : int ; } ^^^^^^^^^^^^^ } ] |
let ( ) = { x = 1 } . x <- 2 [ %% expect { | ^^^^^^^^^^^^^^^^ } ] |
let ( ) = for Some i = 3 to 4 do ( ) done ; [ %% expect { | ^^^^^^ } ] | inherit v as super method m = 0 method x : int = super # m end ; ; [ %% expect { | ^^^^^ } ] |
let x = new v [ %% expect { | ^^^^^ } ] |
let x = object val x = 1 method m = x <- 0 end [ %% expect { | ^^^^ } ] |
let x = object ( self ) method m = self <- 0 end [ %% expect { | ^^^^^^^^ } ] | [ %% expect { | ^^^^^^^^^^^^^^ } ] |
let f x = { < y = x } > [ %% expect { | ^^^^^^^^^^^ } ] | [ %% expect { | ^^^^^^^^^ } ] |
module type empty = sig end
let f ( x : int ) = ( )
let x = f ( module struct end )
module type empty = sig end ^^^^^^^^^^^^^^^^^^^ } ] |
let x = [ % extension_constructor A ]
type t = A ^ } ] |
let x = [ % extension_constructor ] ^^^^^^^^^^^^^^^^^^^^^^^^ } ] |
let x = format_of_string " % z " ^^^^ } ] |
let f ~ x = x + 2
let y = f ~ y : 1 ^ } ] |
let g f = f ~ x : 0 ~ y : 0 ; f ~ y : 0 ~ x : 0 ^ in an order different from other calls . This is only allowed when the real type is known . } ] |
type t = A of { x : int }
let x = A 1
type t = A of { x : int ; } ^^^ } ] |
type ' a t = A of ' a
let rec A x = A ( A ( ) )
type ' a t = A of ' a ^^^ } ] |
let quadratic ( x , x ) = x * x ^ } ] |
type t = A of int | B of float | C
let f ( A x | B x ) = 0
type t = A of int | B of float | C ^^^^^^^^^ int but on the right - hand side it has type float } ] |
let f ( A x | C ) = 0 ^^^^^^^ } ] |
let f ( A x | B y ) = 0 ^^^^^^^^^ } ] |
let f = function # t -> ( )
type t = [ ] ^ } ] |
let f { x ; x = y ; x = z } = x ^^^^^^^^^^^ } ] |
let x = ( [ ` B ] [ ` :> A ] ) ^^^^ [ > ` B ] list but is here used with type [ < ` A ] } ] |
let o = object method m = instance <- 0 end [ %% expect { | ^^^^^^^^^^^^^ } ] |
let x = function | ` azdwbie -> ( ) | ` c7diagq -> ( ) [ %% expect { | ^^^^^^^^ Change one of them . } ] |
let x = ` azdwbie = ` c7diagq [ %% expect { | ^^^^^^^^ Change one of them . } ] |
type ' a x = | X : [ ` > azdwbie ] x | Y : [ ` > c7diagq ] x
let x = function | X -> ( ) | Y -> ( ) [ %% expect { |
type ' a x = X : [ > ` azdwbie ] x | Y : [ > ` c7diagq ] x ^ Change one of them . } ] |
let f = function { x ; y } -> x
type t = { x : unit ; }
type s = { y : unit ; } ^ but is mixed here with fields of type t } ] |
let x = [ % ocaml . error " Expression error " ] ^^^^^^^^^^^ } ] |
let f [ % ocaml . error " Pattern error " ] = ( ) ^^^^^^^^^^^ } ] |
let check f = f ( )
let f ~ x = ( )
let ( ) = check f ; ; } ] |
let ( ) = f ~ y : 1 ^ } ] |
let f ? x ~ a ? y ~ z = ( )
let g = f ? y : None ? x : None ~ a ( ) : ^^^^ ? x ' : a -> a ' : b -> ? y ' : c -> z ' : d -> unit } ] |
let f ( g : ? x : _ -> _ ) = g ~ y : None ? x : None ; g ? x : None ( ) [ %% expect { | ^^^^ } ] |
module Record = struct module type S = sig module Typed_field : Typed_fields_lib . S val form_for_field : ' a Typed_field . t -> ' a Form . t Computation . t end let attach_fieldname_to_error name t = Form . map_error t ~ f ( : Error . tag ~ tag ( : sprintf " in field " ^ name ) ) ...
module Variant = struct module type S = sig module Typed_variant : Typed_variants_lib . S val form_for_variant : ' a Typed_variant . t -> ' a Form . t Computation . t end let make ( type a ) ( module M : S with type Typed_variant . derived_on = a ) = let % sub picker = Elements . Dropd...
type ident = Ident . t Location . loc
type path = Path . t Location . loc
type type_expr = { type_desc : type_desc ; type_loc : Location . t ; type_type : Type0 . type_expr } | Ttyp_var of str option | Ttyp_tuple of type_expr list | Ttyp_arrow of type_expr * type_expr * explicitness * Asttypes . arg_label | Ttyp_ctor of variant | Ttyp_poly of type_expr list * type_...
type field_decl = { fld_ident : ident ; fld_type : type_expr ; fld_loc : Location . t ; fld_fld : Type0 . field_decl }
type ctor_args = | Tctor_tuple of type_expr list | Tctor_record of field_decl list
type ctor_decl = { ctor_ident : ident ; ctor_args : ctor_args ; ctor_ret : type_expr option ; ctor_loc : Location . t ; ctor_ctor : Type0 . ctor_decl }
type type_decl = { tdec_ident : ident ; tdec_params : type_expr list ; tdec_desc : type_decl_desc ; tdec_loc : Location . t ; tdec_tdec : Type0 . type_decl } | Tdec_abstract | Tdec_alias of type_expr | Tdec_record of field_decl list | Tdec_variant of ctor_decl list | Tdec_open | Tdec_extend ...
type pattern = { pat_desc : pattern_desc ; pat_loc : Location . t ; pat_type : Type0 . type_expr } | Tpat_any | Tpat_variable of ident | Tpat_constraint of pattern * type_expr | Tpat_tuple of pattern list | Tpat_or of pattern * pattern | Tpat_literal of literal | Tpat_record of ( path * patt...
type convert_body = { conv_body_desc : convert_body_desc ; conv_body_loc : Location . t ; conv_body_type : Type0 . type_expr } | Tconv_record of ( path * convert_body ) list | Tconv_ctor of path * ( Asttypes . arg_label * convert_body ) list | Tconv_tuple of convert_body list | Tconv_ar...
type expression = { exp_desc : expression_desc ; exp_loc : Location . t ; exp_type : Type0 . type_expr } | Texp_apply of expression * ( explicitness * Asttypes . arg_label * expression ) list | Texp_variable of path | Texp_literal of literal | Texp_fun of Asttypes . arg_label * pattern ...
type conv_type = | Ttconv_with of mode * type_decl | Ttconv_to of type_expr
type signature_item = { sig_desc : signature_desc ; sig_loc : Location . t } | Tsig_value of ident * type_expr | Tsig_instance of ident * type_expr | Tsig_type of type_decl | Tsig_convtype of type_decl * conv_type * ident * type_expr | Tsig_rectype of type_decl list | Tsig_module of ident * modul...
type statement = { stmt_desc : statement_desc ; stmt_loc : Location . t } | Tstmt_value of pattern * expression | Tstmt_instance of ident * expression | Tstmt_type of type_decl | Tstmt_convtype of type_decl * conv_type * ident * convert | Tstmt_rectype of type_decl list | Tstmt_module of ident * ...
type iterator = { type_expr : iterator -> type_expr -> unit ; type_desc : iterator -> type_desc -> unit ; variant : iterator -> variant -> unit ; row_tag : iterator -> row_tag -> unit ; field_decl : iterator -> field_decl -> unit ; ctor_args : iterator -> ctor_args -> unit ; ctor_decl ...
let lid iter { Location . txt ; loc } = iter . longident iter txt ; iter . location iter loc
let str iter ( { Location . txt = _ ; loc } : str ) = iter . location iter loc
let ident iter ( { Location . txt ; loc } : Ident . t Location . loc ) = iter . ident iter txt ; iter . location iter loc
let path iter ( { Location . txt ; loc } : Path . t Location . loc ) = iter . location iter loc ; iter . path iter txt
let type_expr iter { type_desc ; type_loc ; type_type } = iter . location iter type_loc ; iter . type0_expr iter type_type ; iter . type_desc iter type_desc
let type_desc iter = function | Ttyp_var name -> Option . iter ~ f ( : str iter ) name | Ttyp_tuple typs -> List . iter ~ f ( : iter . type_expr iter ) typs | Ttyp_arrow ( typ1 , typ2 , _ , _ ) -> iter . type_expr iter typ1 ; iter . type_expr iter typ2 | Ttyp_ctor variant ->...
let variant iter { var_ident ; var_params } = path iter var_ident ; List . iter ~ f ( : iter . type_expr iter ) var_params
let row_tag iter { rtag_ident ; rtag_arg ; rtag_loc } = ident iter rtag_ident ; iter . location iter rtag_loc ; List . iter ~ f ( : iter . type_expr iter ) rtag_arg
let field_decl iter { fld_ident ; fld_type ; fld_loc ; fld_fld } = iter . location iter fld_loc ; ident iter fld_ident ; iter . type_expr iter fld_type ; ignore fld_fld