123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604(**************************************************************************)(* *)(* OCaml *)(* *)(* Pierre Weis && Damien Doligez, INRIA Rocquencourt *)(* *)(* Copyright 1998 Institut National de Recherche en Informatique et *)(* en Automatique. *)(* *)(* All rights reserved. This file is distributed under the terms of *)(* the GNU Lesser General Public License version 2.1, with the *)(* special exception on linking described in the file LICENSE. *)(* *)(**************************************************************************)(* When you change this, you need to update the documentation:
- man/ocamlc.m
- man/ocamlopt.m
- manual/manual/cmds/comp.etex
- manual/manual/cmds/native.etex
*)typet=|Comment_start(* 1 *)|Comment_not_end(* 2 *)|Deprecatedofstring(* 3 *)|Fragile_matchofstring(* 4 *)|Partial_application(* 5 *)|Labels_omittedofstringlist(* 6 *)|Method_overrideofstringlist(* 7 *)|Partial_matchofstring(* 8 *)|Non_closed_record_patternofstring(* 9 *)|Statement_type(* 10 *)|Unused_match(* 11 *)|Unused_pat(* 12 *)|Instance_variable_overrideofstringlist(* 13 *)|Illegal_backslash(* 14 *)|Implicit_public_methodsofstringlist(* 15 *)|Unerasable_optional_argument(* 16 *)|Undeclared_virtual_methodofstring(* 17 *)|Not_principalofstring(* 18 *)|Without_principalityofstring(* 19 *)|Unused_argument(* 20 *)|Nonreturning_statement(* 21 *)|Preprocessorofstring(* 22 *)|Useless_record_with(* 23 *)|Bad_module_nameofstring(* 24 *)|All_clauses_guarded(* 8, used to be 25 *)|Unused_varofstring(* 26 *)|Unused_var_strictofstring(* 27 *)|Wildcard_arg_to_constant_constr(* 28 *)|Eol_in_string(* 29 *)|Duplicate_definitionsofstring*string*string*string(*30 *)|Multiple_definitionofstring*string*string(* 31 *)|Unused_value_declarationofstring(* 32 *)|Unused_openofstring(* 33 *)|Unused_type_declarationofstring(* 34 *)|Unused_for_indexofstring(* 35 *)|Unused_ancestorofstring(* 36 *)|Unused_constructorofstring*bool*bool(* 37 *)|Unused_extensionofstring*bool*bool*bool(* 38 *)|Unused_rec_flag(* 39 *)|Name_out_of_scopeofstring*stringlist*bool(* 40 *)|Ambiguous_nameofstringlist*stringlist*bool(* 41 *)|Disambiguated_nameofstring(* 42 *)|Nonoptional_labelofstring(* 43 *)|Open_shadow_identifierofstring*string(* 44 *)|Open_shadow_label_constructorofstring*string(* 45 *)|Bad_env_variableofstring*string(* 46 *)|Attribute_payloadofstring*string(* 47 *)|Eliminated_optional_argumentsofstringlist(* 48 *)|No_cmi_fileofstring*stringoption(* 49 *)|Bad_docstringofbool(* 50 *)|Expect_tailcall(* 51 *)|Fragile_literal_pattern(* 52 *)|Misplaced_attributeofstring(* 53 *)|Duplicated_attributeofstring(* 54 *)|Inlining_impossibleofstring(* 55 *)|Unreachable_case(* 56 *)|Ambiguous_patternofstringlist(* 57 *)|No_cmx_fileofstring(* 58 *)|Assignment_to_non_mutable_value(* 59 *)|Unused_moduleofstring(* 60 *)|Unboxable_type_in_prim_declofstring(* 61 *);;(* If you remove a warning, leave a hole in the numbering. NEVER change
the numbers of existing warnings.
If you add a new warning, add it at the end with a new number;
do NOT reuse one of the holes.
*)letnumber=function|Comment_start->1|Comment_not_end->2|Deprecated_->3|Fragile_match_->4|Partial_application->5|Labels_omitted_->6|Method_override_->7|Partial_match_->8|Non_closed_record_pattern_->9|Statement_type->10|Unused_match->11|Unused_pat->12|Instance_variable_override_->13|Illegal_backslash->14|Implicit_public_methods_->15|Unerasable_optional_argument->16|Undeclared_virtual_method_->17|Not_principal_->18|Without_principality_->19|Unused_argument->20|Nonreturning_statement->21|Preprocessor_->22|Useless_record_with->23|Bad_module_name_->24|All_clauses_guarded->8(* used to be 25 *)|Unused_var_->26|Unused_var_strict_->27|Wildcard_arg_to_constant_constr->28|Eol_in_string->29|Duplicate_definitions_->30|Multiple_definition_->31|Unused_value_declaration_->32|Unused_open_->33|Unused_type_declaration_->34|Unused_for_index_->35|Unused_ancestor_->36|Unused_constructor_->37|Unused_extension_->38|Unused_rec_flag->39|Name_out_of_scope_->40|Ambiguous_name_->41|Disambiguated_name_->42|Nonoptional_label_->43|Open_shadow_identifier_->44|Open_shadow_label_constructor_->45|Bad_env_variable_->46|Attribute_payload_->47|Eliminated_optional_arguments_->48|No_cmi_file_->49|Bad_docstring_->50|Expect_tailcall->51|Fragile_literal_pattern->52|Misplaced_attribute_->53|Duplicated_attribute_->54|Inlining_impossible_->55|Unreachable_case->56|Ambiguous_pattern_->57|No_cmx_file_->58|Assignment_to_non_mutable_value->59|Unused_module_->60|Unboxable_type_in_prim_decl_->61;;letlast_warning_number=61;;(* Must be the max number returned by the [number] function. *)letletter=function|'a'->letrecloopi=ifi=0then[]elsei::loop(i-1)inlooplast_warning_number|'b'->[]|'c'->[1;2]|'d'->[3]|'e'->[4]|'f'->[5]|'g'->[]|'h'->[]|'i'->[]|'j'->[]|'k'->[32;33;34;35;36;37;38;39]|'l'->[6]|'m'->[7]|'n'->[]|'o'->[]|'p'->[8]|'q'->[]|'r'->[9]|'s'->[10]|'t'->[]|'u'->[11;12]|'v'->[13]|'w'->[]|'x'->[14;15;16;17;18;19;20;21;22;23;24;30]|'y'->[26]|'z'->[27]|_->assertfalse;;typestate={active:boolarray;error:boolarray;}letcurrent=ref{active=Array.make(last_warning_number+1)true;error=Array.make(last_warning_number+1)false;}letbackup()=!currentletrestorex=current:=xletis_activex=(!current).active.(numberx);;letis_errorx=(!current).error.(numberx);;letparse_opterroractiveflagss=letseti=flags.(i)<-trueinletcleari=flags.(i)<-falseinletset_alli=active.(i)<-true;error.(i)<-trueinleterror()=raise(Arg.Bad"Ill-formed list of warnings")inletrecget_numni=ifi>=String.lengthstheni,nelsematchs.[i]with|'0'..'9'->get_num(10*n+Char.codes.[i]-Char.code'0')(i+1)|_->i,ninletget_rangei=leti,n1=get_num0iinifi+2<String.lengths&&s.[i]='.'&&s.[i+1]='.'thenleti,n2=get_num0(i+2)inifn2<n1thenerror();i,n1,n2elsei,n1,n1inletrecloopi=ifi>=String.lengthsthen()elsematchs.[i]with|'A'..'Z'->List.iterset(letter(Char.lowercase_asciis.[i]));loop(i+1)|'a'..'z'->List.iterclear(letters.[i]);loop(i+1)|'+'->loop_letter_numset(i+1)|'-'->loop_letter_numclear(i+1)|'@'->loop_letter_numset_all(i+1)|_->error()andloop_letter_nummyseti=ifi>=String.lengthsthenerror()elsematchs.[i]with|'0'..'9'->leti,n1,n2=get_rangeiinforn=n1tominn2last_warning_numberdomysetndone;loopi|'A'..'Z'->List.itermyset(letter(Char.lowercase_asciis.[i]));loop(i+1)|'a'..'z'->List.itermyset(letters.[i]);loop(i+1)|_->error()inloop0;;letparse_optionserrflags=leterror=Array.copy(!current).errorinletactive=Array.copy(!current).activeinparse_opterroractive(iferrflagthenerrorelseactive)s;current:={error;active}(* If you change these, don't forget to change them in man/ocamlc.m *)letdefaults_w="+a-4-6-7-9-27-29-32..39-41..42-44-45-48-50-60";;letdefaults_warn_error="-a+31";;let()=parse_optionsfalsedefaults_w;;let()=parse_optionstruedefaults_warn_error;;letmessage=function|Comment_start->"this is the start of a comment."|Comment_not_end->"this is not the end of a comment."|Deprecateds->(* Reduce \r\n to \n:
- Prevents any \r characters being printed on Unix when processing
Windows sources
- Prevents \r\r\n being generated on Windows, which affects the
testsuite
*)"deprecated: "^Misc.normalise_eols|Fragile_match""->"this pattern-matching is fragile."|Fragile_matchs->"this pattern-matching is fragile.\n\
It will remain exhaustive when constructors are added to type "^s^"."|Partial_application->"this function application is partial,\n\
maybe some arguments are missing."|Labels_omitted[]->assertfalse|Labels_omitted[l]->"label "^l^" was omitted in the application of this function."|Labels_omittedls->"labels "^String.concat", "ls^" were omitted in the application of this function."|Method_override[lab]->"the method "^lab^" is overridden."|Method_override(cname::slist)->String.concat" "("the following methods are overridden by the class"::cname::":\n "::slist)|Method_override[]->assertfalse|Partial_match""->"this pattern-matching is not exhaustive."|Partial_matchs->"this pattern-matching is not exhaustive.\n\
Here is an example of a case that is not matched:\n"^s|Non_closed_record_patterns->"the following labels are not bound in this record pattern:\n"^s^"\nEither bind these labels explicitly or add '; _' to the pattern."|Statement_type->"this expression should have type unit."|Unused_match->"this match case is unused."|Unused_pat->"this sub-pattern is unused."|Instance_variable_override[lab]->"the instance variable "^lab^" is overridden.\n"^"The behaviour changed in ocaml 3.10 (previous behaviour was hiding.)"|Instance_variable_override(cname::slist)->String.concat" "("the following instance variables are overridden by the class"::cname::":\n "::slist)^"\nThe behaviour changed in ocaml 3.10 (previous behaviour was hiding.)"|Instance_variable_override[]->assertfalse|Illegal_backslash->"illegal backslash escape in string."|Implicit_public_methodsl->"the following private methods were made public implicitly:\n "^String.concat" "l^"."|Unerasable_optional_argument->"this optional argument cannot be erased."|Undeclared_virtual_methodm->"the virtual method "^m^" is not declared."|Not_principals->s^" is not principal."|Without_principalitys->s^" without principality."|Unused_argument->"this argument will not be used by the function."|Nonreturning_statement->"this statement never returns (or has an unsound type.)"|Preprocessors->s|Useless_record_with->"all the fields are explicitly listed in this record:\n\
the 'with' clause is useless."|Bad_module_name(modname)->"bad source file name: \""^modname^"\" is not a valid module name."|All_clauses_guarded->"this pattern-matching is not exhaustive.\n\
All clauses in this pattern-matching are guarded."|Unused_varv|Unused_var_strictv->"unused variable "^v^"."|Wildcard_arg_to_constant_constr->"wildcard pattern given as argument to a constant constructor"|Eol_in_string->"unescaped end-of-line in a string constant (non-portable code)"|Duplicate_definitions(kind,cname,tc1,tc2)->Printf.sprintf"the %s %s is defined in both types %s and %s."kindcnametc1tc2|Multiple_definition(modname,file1,file2)->Printf.sprintf"files %s and %s both define a module named %s"file1file2modname|Unused_value_declarationv->"unused value "^v^"."|Unused_opens->"unused open "^s^"."|Unused_type_declarations->"unused type "^s^"."|Unused_for_indexs->"unused for-loop index "^s^"."|Unused_ancestors->"unused ancestor variable "^s^"."|Unused_constructor(s,false,false)->"unused constructor "^s^"."|Unused_constructor(s,true,_)->"constructor "^s^" is never used to build values.\n\
(However, this constructor appears in patterns.)"|Unused_constructor(s,false,true)->"constructor "^s^" is never used to build values.\n\
Its type is exported as a private type."|Unused_extension(s,is_exception,cu_pattern,cu_privatize)->letkind=ifis_exceptionthen"exception"else"extension constructor"inletname=kind^" "^sinbeginmatchcu_pattern,cu_privatizewith|false,false->"unused "^name|true,_->name^" is never used to build values.\n\
(However, this constructor appears in patterns.)"|false,true->name^" is never used to build values.\n\
It is exported or rebound as a private extension."end|Unused_rec_flag->"unused rec flag."|Name_out_of_scope(ty,[nm],false)->nm^" was selected from type "^ty^".\nIt is not visible in the current scope, and will not \n\
be selected if the type becomes unknown."|Name_out_of_scope(_,_,false)->assertfalse|Name_out_of_scope(ty,slist,true)->"this record of type "^ty^" contains fields that are \n\
not visible in the current scope: "^String.concat" "slist^".\n\
They will not be selected if the type becomes unknown."|Ambiguous_name([s],tl,false)->s^" belongs to several types: "^String.concat" "tl^"\nThe first one was selected. Please disambiguate if this is wrong."|Ambiguous_name(_,_,false)->assertfalse|Ambiguous_name(_slist,tl,true)->"these field labels belong to several types: "^String.concat" "tl^"\nThe first one was selected. Please disambiguate if this is wrong."|Disambiguated_names->"this use of "^s^" relies on type-directed disambiguation,\n\
it will not compile with OCaml 4.00 or earlier."|Nonoptional_labels->"the label "^s^" is not optional."|Open_shadow_identifier(kind,s)->Printf.sprintf"this open statement shadows the %s identifier %s (which is later used)"kinds|Open_shadow_label_constructor(kind,s)->Printf.sprintf"this open statement shadows the %s %s (which is later used)"kinds|Bad_env_variable(var,s)->Printf.sprintf"illegal environment variable %s : %s"vars|Attribute_payload(a,s)->Printf.sprintf"illegal payload for attribute '%s'.\n%s"as|Eliminated_optional_argumentssl->Printf.sprintf"implicit elimination of optional argument%s %s"(ifList.lengthsl=1then""else"s")(String.concat", "sl)|No_cmi_file(name,None)->"no cmi file was found in path for module "^name|No_cmi_file(name,Somemsg)->Printf.sprintf"no valid cmi file was found in path for module %s. %s"namemsg|Bad_docstringunattached->ifunattachedthen"unattached documentation comment (ignored)"else"ambiguous documentation comment"|Expect_tailcall->Printf.sprintf"expected tailcall"|Fragile_literal_pattern->Printf.sprintf"Code should not depend on the actual values of\n\
this constructor's arguments. They are only for information\n\
and may change in future versions. (See manual section 8.5)"|Unreachable_case->"this match case is unreachable.\n\
Consider replacing it with a refutation case '<pat> -> .'"|Misplaced_attributeattr_name->Printf.sprintf"the %S attribute cannot appear in this context"attr_name|Duplicated_attributeattr_name->Printf.sprintf"the %S attribute is used more than once on this \
expression"attr_name|Inlining_impossiblereason->Printf.sprintf"Cannot inline: %s"reason|Ambiguous_patternvars->letmsg=letvars=List.sortString.comparevarsinmatchvarswith|[]->assertfalse|[x]->"variable "^x|_::_->"variables "^String.concat","varsinPrintf.sprintf"Ambiguous or-pattern variables under guard;\n\
%s may match different arguments. (See manual section 8.5)"msg|No_cmx_filename->Printf.sprintf"no cmx file was found in path for module %s, \
and its interface was not compiled with -opaque"name|Assignment_to_non_mutable_value->"A potential assignment to a non-mutable value was detected \n\
in this source file. Such assignments may generate incorrect code \n\
when using Flambda."|Unused_modules->"unused module "^s^"."|Unboxable_type_in_prim_declt->Printf.sprintf"This primitive declaration uses type %s, which is unannotated and\n\
unboxable. The representation of such types may change in future\n\
versions. You should annotate the declaration of %s with [@@boxed]\n\
or [@@unboxed]."tt;;letnerrors=ref0;;letprintppfw=letmsg=messagewinletnum=numberwinFormat.fprintfppf"%d: %s"nummsg;Format.pp_print_flushppf();if(!current).error.(num)thenincrnerrors;;exceptionErrorsofint;;letreset_fatal()=nerrors:=0letcheck_fatal()=if!nerrors>0thenbeginlete=Errors!nerrorsinnerrors:=0;raisee;end;;;letdescriptions=[1,"Suspicious-looking start-of-comment mark.";2,"Suspicious-looking end-of-comment mark.";3,"Deprecated feature.";4,"Fragile pattern matching: matching that will remain complete even\n\
\ if additional constructors are added to one of the variant types\n\
\ matched.";5,"Partially applied function: expression whose result has function\n\
\ type and is ignored.";6,"Label omitted in function application.";7,"Method overridden.";8,"Partial match: missing cases in pattern-matching.";9,"Missing fields in a record pattern.";10,"Expression on the left-hand side of a sequence that doesn't have \
type\n\
\ \"unit\" (and that is not a function, see warning number 5).";11,"Redundant case in a pattern matching (unused match case).";12,"Redundant sub-pattern in a pattern-matching.";13,"Instance variable overridden.";14,"Illegal backslash escape in a string constant.";15,"Private method made public implicitly.";16,"Unerasable optional argument.";17,"Undeclared virtual method.";18,"Non-principal type.";19,"Type without principality.";20,"Unused function argument.";21,"Non-returning statement.";22,"Preprocessor warning.";23,"Useless record \"with\" clause.";24,"Bad module name: the source file name is not a valid OCaml module \
name.";(* 25, "Pattern-matching with all clauses guarded. Exhaustiveness cannot \
be\n\
\ checked."; (* Now part of warning 8 *) *)26,"Suspicious unused variable: unused variable that is bound\n\
\ with \"let\" or \"as\", and doesn't start with an underscore (\"_\")\n\
\ character.";27,"Innocuous unused variable: unused variable that is not bound with\n\
\ \"let\" nor \"as\", and doesn't start with an underscore (\"_\")\n\
\ character.";28,"Wildcard pattern given as argument to a constant constructor.";29,"Unescaped end-of-line in a string constant (non-portable code).";30,"Two labels or constructors of the same name are defined in two\n\
\ mutually recursive types.";31,"A module is linked twice in the same executable.";32,"Unused value declaration.";33,"Unused open statement.";34,"Unused type declaration.";35,"Unused for-loop index.";36,"Unused ancestor variable.";37,"Unused constructor.";38,"Unused extension constructor.";39,"Unused rec flag.";40,"Constructor or label name used out of scope.";41,"Ambiguous constructor or label name.";42,"Disambiguated constructor or label name (compatibility warning).";43,"Nonoptional label applied as optional.";44,"Open statement shadows an already defined identifier.";45,"Open statement shadows an already defined label or constructor.";46,"Error in environment variable.";47,"Illegal attribute payload.";48,"Implicit elimination of optional arguments.";49,"Absent cmi file when looking up module alias.";50,"Unexpected documentation comment.";51,"Warning on non-tail calls if @tailcall present.";52,"Fragile constant pattern.";53,"Attribute cannot appear in this context";54,"Attribute used more than once on an expression";55,"Inlining impossible";56,"Unreachable case in a pattern-matching (based on type information).";57,"Ambiguous or-pattern variables under guard";58,"Missing cmx file";59,"Assignment to non-mutable value";60,"Unused module declaration";];;lethelp_warnings()=List.iter(fun(i,s)->Printf.printf"%3i %s\n"is)descriptions;print_endline" A all warnings";fori=Char.code'b'toChar.code'z'doletc=Char.chriinmatchlettercwith|[]->()|[n]->Printf.printf" %c Alias for warning %i.\n"(Char.uppercase_asciic)n|l->Printf.printf" %c warnings %s.\n"(Char.uppercase_asciic)(String.concat", "(List.mapstring_of_intl))done;exit0;;