Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file warnings.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205openPpxlibopenUtilstypekind=|Return_unit_without_modifiesofstring|Invalid_coercion_typeofstring|Coercion_cycleof(string*string*string)list|Coercion_already_definedof(string*string*string)list|Not_a_constructorofstring|Formula_expected|Term_expected|Duplicated_variableofstring|Unbound_variableofstring|Pattern_bad_typeofstring*string|Bad_typeofstring*string|Bad_arityofstring*int*int|Bad_type_arityofstring*int*int|Name_clashofstring|Syntax_error|Illegal_characterofchar|Illegal_escapeofstring*stringoption|Unterminated_comment|Duplicated_argumentofstring|Unsupportedofstring|Type_checking_errorofstring|Module_not_foundofstring|Free_variablesofstringlist|Invalid_int_literalofstring*charoption|Symbol_not_foundofstringlist|Bad_record_fieldofstring|Public_type_invariantofstring|Circular_open|Field_applicationofstring|Duplicated_record_fieldofstring|Partial_applicationofstring|Unknown_record_fieldofstring|Cyclic_type_declarationofstring|Predicate_symbol_expectedofstring|Function_symbol_expectedofstring|Pattern_not_exhaustiveofstring|Pattern_guard_not_exhaustiveofstring|Pattern_fully_guarded|Pattern_redundantofstring|Ambiguous_pattern|Old_in_precondofstringtypeerror=location*kindexceptionErroroferrorleterror~lock=raise(Error(loc,k))lettype_checking_error~locs=error~loc(Type_checking_errors)letunsupported~locs=error~loc(Unsupporteds)openFmtletfunction_ppf(f,t1,t2)=pfppf"%s: %s -> %s"ft1t2letpp_kindppf=function|Return_unit_without_modifiesf->pfppf"The function %s returns unit@ but its specifications does not contain \
any modifies clause"f|Invalid_coercion_typef->pfppf"The function %s does not have a valid coercion type"f|Coercion_cyclefl->pfppf"This coercion introduces a cycle:@\n @[%a@]"(list~sep:newlinefunction_)fl|Coercion_already_definedfl->pfppf"A coercion between these types already exists:@\n @[%a@]"(list~sep:newlinefunction_)fl|Not_a_constructorf->pfppf"The symbol %s is not a constructor"f|Formula_expected->pfppf"A formula was expected"|Term_expected->pfppf"A term was expected"|Duplicated_variables->pfppf"The variable %s is duplicated in this pattern"s|Unbound_variables->pfppf"The variable %s does not appear in this pattern"s|Pattern_bad_type(t1,t2)->pfppf"This pattern matches values of type %s@ but a pattern was expected \
which matches values of type@ %s"t1t2|Bad_type(t1,t2)->pfppf"This term has type %s@ but a term was expected of type@ %s"t1t2|Bad_arity(f,expected,got)->pfppf"The constructor %s expects %d argument(s)@ but is applied to %d \
argument(s) here"fexpectedgot|Name_clashs->pfppf"A declaration for %s already exists in this context"s|Syntax_error->pfppf"Syntax error"|Illegal_characterc->pfppf"Illegal character %c"c|Unterminated_comment->pfppf"Unterminated comment"|Illegal_escape(s,explanation)->pfppf"Illegal backslash escape in string or character (%s)%a"s(option(fmt": %s"))explanation|Duplicated_argumentarg->pfppf"Duplicated argument %s"arg|Unsupporteds->pfppf"Not yet supported: %s"s|Type_checking_errormsg->pfppf"Type checking error: %a"textmsg|Module_not_foundm->pfppf"No module with name %s"m|Free_variablesvl->pfppf"Unbound variables: %a"(list~sep:commastring)vl|Invalid_int_literal(s,c)->pfppf"Invalid int literal: %s%a"s(optionchar)c|Symbol_not_foundsl->pfppf"Symbol %a not found in scope@ (see \"Symbols in scope\" documentation \
page)"(list~sep:(conststring".")string)sl|Bad_record_fieldf->pfppf"The record field %s does not exist"f|Public_type_invariantt->pfppf"Invariant on public type %s"t|Circular_open->pfppf"This open introduces a dependency cycle"|Field_applicationf->pfppf"The record field %s cannot be applied"f|Duplicated_record_fieldf->pfppf"A record field with name %s already exists"f|Partial_applications->pfppf"The symbol %s cannot be partially applied"s|Unknown_record_fields->pfppf"The field %s is unknown"s|Bad_type_arity(t,expected,got)->pfppf"The type %s expects %d argument(s)@ but was given %d argument(s) here"texpectedgot|Cyclic_type_declarationt->pfppf"The type declaration for %s contains a cycle"t|Predicate_symbol_expecteds->pfppf"Not a predicate symbol: %s"s|Function_symbol_expecteds->pfppf"Not a function symbol: %s"s|Pattern_not_exhaustivep->pfppf"This pattern-matching is not exhaustive.@\n\
Here is an example of a case that is not matched:@\n\
\ %s"p|Pattern_guard_not_exhaustivep->pfppf"This pattern-matching may not be exhaustive because of the guard.@\n\
Here is an example of a case that may not be matched:@\n\
\ %s"p|Ambiguous_pattern->pfppf"Or-patterns are prohibited under guards to avoid ambiguities@ (see \
OCaml compiler warning 57)"|Pattern_fully_guarded->pfppf"All clauses in this pattern-matching are guarded"|Pattern_redundantp->pfppf"The pattern-matching is redundant.@\n\
Here is a case that is unused:@\n\
\ %s"p|Old_in_precondprecond->pfppf"old operator is not allowed in %s clauses"precondletstyled_listlpp=List.fold_left(funaccx->styledxacc)ppl(** [pp_gen pp_sort pp_kind ppf loc k] display the message of the given sort
(warning, error, etc.) at the location obtained after fixing [loc] (it might
have been broken by preprocessing *)letpp_genpp_sortpp_kindppflock=letinput_filename=loc.loc_start.pos_fnameinmatchinput_filenamewith|""->pfppf"Internal error: no filename location for the following error@.%a: \
@[%a.@]"pp_sortkpp_kindk|"_none_"->(* This location is used for builtins such as [list] *)pfppf"%a: @[%a.@]"pp_sortkpp_kindk|_->letinput=Pp_loc.Input.fileinput_filenamein(* because of the preprocessor (gospel pps), we may obtain locations that:
- have correct line numbers and correct offsets within a line (pos_cnum -
pos_bol) (where "correct" means that they refer to the user-written file
before preprocessing); but
- where the [pos_cnum] and [pos_bol] fields refer to offsets within the
file *after* preprocessing rather than *before*.
We thus use helpers from [Pp_loc.Position] to recompute full positions from
line/column numbers with respect to the input file before preprocessing.
*)letrepair_pos(p:Lexing.position):Lexing.position=Pp_loc.Position.of_line_colp.pos_lnum(p.pos_cnum-p.pos_bol+1)|>Pp_loc.Position.to_lexing~filename:input_filenameinputinletstart_pos,end_pos=(repair_posloc.loc_start,repair_posloc.loc_end)inpfppf"%a@\n%a%a: @[%a.@]"(styled`BoldLocation.print){loc_start=start_pos;loc_end=end_pos;loc_ghost=false}(Pp_loc.pp~max_lines:10~input)[(Pp_loc.Position.of_lexingstart_pos,Pp_loc.Position.of_lexingend_pos);]pp_sortkpp_kindkletpp_warningppf_=styled_list[`Magenta;`Bold]stringppf"Warning"letpp_errorppf_=styled_list[`Red;`Bold]stringppf"Error"letppppf(loc,k)=pp_genpp_errorpp_kindppflock