You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(* taken from https://github.com/BuckleScript/ocaml/blob/d4144647d1bf9bc7dc3aadc24c25a7efa3a67915/utils/warnings.ml#L251 *)
114621
114622
(* actual modified message branches are commented *)
114622
-
let message = Warnings.(function
114623
-
| Comment_start -> "this is the start of a comment."
114624
-
| Comment_not_end -> "this is not the end of a comment."
114623
+
let message (warning : Warnings.t) =
114624
+
match warning with
114625
114625
| Deprecated s -> s ^ " is deprecated. "
114626
-
| Fragile_match "" ->
114627
-
"this pattern-matching is fragile."
114628
-
| Fragile_match s ->
114629
-
"this pattern-matching is fragile.\n\
114630
-
It will remain exhaustive when constructors are added to type " ^ s ^ "."
114631
-
| Partial_application ->
114632
-
"this function application is partial,\n\
114633
-
maybe some arguments are missing."
114634
-
| Labels_omitted ->
114635
-
"labels were omitted in the application of this function."
114636
-
| Method_override [lab] ->
114637
-
"the method " ^ lab ^ " is overridden."
114638
-
| Method_override (cname :: slist) ->
114639
-
String.concat " "
114640
-
("the following methods are overridden by the class"
114641
-
:: cname :: ":\n " :: slist)
114642
-
| Method_override [] -> assert false
114643
114626
| Partial_match "" ->
114644
-
(* modified *)
114645
114627
"You forgot to handle a possible value here, though we don't have more information on the value."
114646
114628
| Partial_match s ->
114647
-
(* modified *)
114648
114629
"You forgot to handle a possible value here, for example: \n" ^ s
114649
-
| Non_closed_record_pattern s ->
114650
-
"the following labels are not bound in this record pattern:\n" ^ s ^
114651
-
"\nEither bind these labels explicitly or add '; _' to the pattern."
114652
-
| Statement_type ->
114653
-
"this expression should have type unit."
114654
-
| Unused_match -> "this match case is unused."
114655
-
| Unused_pat -> "this sub-pattern is unused."
114656
-
| Instance_variable_override [lab] ->
114657
-
"the instance variable " ^ lab ^ " is overridden.\n" ^
114658
-
"The behaviour changed in ocaml 3.10 (previous behaviour was hiding.)"
114659
-
| Instance_variable_override (cname :: slist) ->
114660
-
String.concat " "
114661
-
("the following instance variables are overridden by the class"
114662
-
:: cname :: ":\n " :: slist) ^
114663
-
"\nThe behaviour changed in ocaml 3.10 (previous behaviour was hiding.)"
114664
-
| Instance_variable_override [] -> assert false
114665
-
| Illegal_backslash -> "illegal backslash escape in string."
114666
-
| Implicit_public_methods l ->
114667
-
"the following private methods were made public implicitly:\n "
114668
-
^ String.concat " " l ^ "."
114669
114630
| Unerasable_optional_argument ->
114670
-
(* modified *)
114671
-
(* TODO: better formatting *)
114672
114631
String.concat "\n\n"
114673
114632
["This is an optional argument at the final position of the function; omitting it while calling the function might be confused with currying. For example:";
114674
114633
" let myTitle = displayTitle \"hello!\";";
114675
114634
"if `displayTitle` accepts an optional argument at the final position, it'd be unclear whether `myTitle` is a curried function or the final result.";
114676
114635
"Here's the language's rule: an optional argument is erased as soon as the 1st positional (i.e. neither labeled nor optional) argument defined after it is passed in.";
114677
114636
"To solve this, you'd conventionally add an extra () argument at the end of the function declaration."]
114678
-
| Undeclared_virtual_method m -> "the virtual method "^m^" is not declared."
114679
-
| Not_principal s -> s^" is not principal."
114680
-
| Without_principality s -> s^" without principality."
114681
-
| Unused_argument -> "this argument will not be used by the function."
114682
-
| Nonreturning_statement ->
114683
-
"this statement never returns (or has an unsound type.)"
114684
-
| Preprocessor s -> s
114685
-
| Useless_record_with ->
114686
-
"all the fields are explicitly listed in this record:\n\
114687
-
the 'with' clause is useless."
114688
114637
| Bad_module_name (modname) ->
114689
-
(* modified *)
114690
114638
"This file's name is potentially invalid. The build systems conventionally turn a file name into a module name by upper-casing the first letter. " ^ modname ^ " isn't a valid module name.\n" ^
114691
114639
"Note: some build systems might e.g. turn kebab-case into CamelCase module, which is why this isn't a hard error."
114692
-
| All_clauses_guarded ->
114693
-
"bad style, all clauses in this pattern-matching are guarded."
114694
-
| Unused_var v | Unused_var_strict v -> "unused variable " ^ v ^ "."
114695
-
| Wildcard_arg_to_constant_constr ->
114696
-
"wildcard pattern given as argument to a constant constructor"
114697
-
| Eol_in_string ->
114698
-
"unescaped end-of-line in a string constant (non-portable code)"
(* taken from https://github.com/BuckleScript/ocaml/blob/d4144647d1bf9bc7dc3aadc24c25a7efa3a67915/utils/warnings.ml#L251 *)
3
3
(* actual modified message branches are commented *)
4
-
let message =Warnings.(function
5
-
|Comment_start -> "this is the start of a comment."
6
-
|Comment_not_end -> "this is not the end of a comment."
4
+
letmessage (warning: Warnings.t) =
5
+
match warning with
7
6
|Deprecateds -> s ^" is deprecated. "
8
-
|Fragile_match"" ->
9
-
"this pattern-matching is fragile."
10
-
|Fragile_matchs ->
11
-
"this pattern-matching is fragile.\n\
12
-
It will remain exhaustive when constructors are added to type "^ s ^"."
13
-
|Partial_application ->
14
-
"this function application is partial,\n\
15
-
maybe some arguments are missing."
16
-
|Labels_omitted ->
17
-
"labels were omitted in the application of this function."
18
-
|Method_override [lab] ->
19
-
"the method "^ lab ^" is overridden."
20
-
|Method_override (cname :: slist) ->
21
-
String.concat ""
22
-
("the following methods are overridden by the class"
23
-
:: cname :: ":\n" :: slist)
24
-
|Method_override[] -> assertfalse
25
7
|Partial_match"" ->
26
-
(* modified *)
27
8
"You forgot to handle a possible value here, though we don't have more information on the value."
28
9
|Partial_matchs ->
29
-
(* modified *)
30
10
"You forgot to handle a possible value here, for example: \n"^ s
31
-
|Non_closed_record_patterns ->
32
-
"the following labels are not bound in this record pattern:\n"^ s ^
33
-
"\nEither bind these labels explicitly or add '; _' to the pattern."
34
-
|Statement_type ->
35
-
"this expression should have type unit."
36
-
|Unused_match -> "this match case is unused."
37
-
|Unused_pat -> "this sub-pattern is unused."
38
-
|Instance_variable_override [lab] ->
39
-
"the instance variable "^ lab ^" is overridden.\n"^
40
-
"The behaviour changed in ocaml 3.10 (previous behaviour was hiding.)"
41
-
|Instance_variable_override (cname :: slist) ->
42
-
String.concat ""
43
-
("the following instance variables are overridden by the class"
44
-
:: cname :: ":\n" :: slist) ^
45
-
"\nThe behaviour changed in ocaml 3.10 (previous behaviour was hiding.)"
46
-
|Instance_variable_override[] -> assertfalse
47
-
|Illegal_backslash -> "illegal backslash escape in string."
48
-
|Implicit_public_methodsl ->
49
-
"the following private methods were made public implicitly:\n"
50
-
^String.concat "" l ^"."
51
11
|Unerasable_optional_argument ->
52
-
(* modified *)
53
-
(* TODO: better formatting *)
54
12
String.concat "\n\n"
55
13
["This is an optional argument at the final position of the function; omitting it while calling the function might be confused with currying. For example:";
56
14
" let myTitle = displayTitle \"hello!\";";
57
15
"if `displayTitle` accepts an optional argument at the final position, it'd be unclear whether `myTitle` is a curried function or the final result.";
58
16
"Here's the language's rule: an optional argument is erased as soon as the 1st positional (i.e. neither labeled nor optional) argument defined after it is passed in.";
59
17
"To solve this, you'd conventionally add an extra () argument at the end of the function declaration."]
60
-
|Undeclared_virtual_methodm -> "the virtual method "^m^" is not declared."
61
-
|Not_principals -> s^" is not principal."
62
-
|Without_principalitys -> s^" without principality."
63
-
|Unused_argument -> "this argument will not be used by the function."
64
-
|Nonreturning_statement ->
65
-
"this statement never returns (or has an unsound type.)"
66
-
|Preprocessors -> s
67
-
|Useless_record_with ->
68
-
"all the fields are explicitly listed in this record:\n\
69
-
the 'with' clause is useless."
70
18
|Bad_module_name (modname) ->
71
-
(* modified *)
72
19
"This file's name is potentially invalid. The build systems conventionally turn a file name into a module name by upper-casing the first letter. "^ modname ^" isn't a valid module name.\n"^
73
20
"Note: some build systems might e.g. turn kebab-case into CamelCase module, which is why this isn't a hard error."
74
-
|All_clauses_guarded ->
75
-
"bad style, all clauses in this pattern-matching are guarded."
76
-
|Unused_varv|Unused_var_strictv -> "unused variable "^ v ^"."
77
-
|Wildcard_arg_to_constant_constr ->
78
-
"wildcard pattern given as argument to a constant constructor"
79
-
|Eol_in_string ->
80
-
"unescaped end-of-line in a string constant (non-portable code)"
81
-
|Duplicate_definitions (kind, cname, tc1, tc2) ->
82
-
Printf.sprintf "the %s %s is defined in both types %s and %s."
83
-
kind cname tc1 tc2
84
-
|Multiple_definition(modname, file1, file2) ->
85
-
Printf.sprintf
86
-
"files %s and %s both define a module named %s"
87
-
file1 file2 modname
88
-
|Unused_value_declarationv -> "unused value "^ v ^"."
89
-
|Unused_opens -> "unused open "^ s ^"."
90
-
|Unused_type_declarations -> "unused type "^ s ^"."
91
-
|Unused_for_indexs -> "unused for-loop index "^ s ^"."
92
-
|Unused_ancestors -> "unused ancestor variable "^ s ^"."
93
-
|Unused_constructor (s, false, false) -> "unused constructor "^ s ^"."
94
-
|Unused_constructor (s, true, _) ->
95
-
"constructor "^ s ^
96
-
" is never used to build values.\n\
97
-
(However, this constructor appears in patterns.)"
98
-
|Unused_constructor (s, false, true) ->
99
-
"constructor "^ s ^
100
-
" is never used to build values.\n\
101
-
Its type is exported as a private type."
102
-
|Unused_extension (s, false, false) ->
103
-
"unused extension constructor "^ s ^"."
104
-
|Unused_extension (s, true, _) ->
105
-
"extension constructor "^ s ^
106
-
" is never used to build values.\n\
107
-
(However, this constructor appears in patterns.)"
108
-
|Unused_extension (s, false, true) ->
109
-
"extension constructor "^ s ^
110
-
" is never used to build values.\n\
111
-
It is exported or rebound as a private extension."
112
-
|Unused_rec_flag ->
113
-
"unused rec flag."
114
-
|Name_out_of_scope (ty, [nm], false) ->
115
-
nm ^" was selected from type "^ ty ^
116
-
".\nIt is not visible in the current scope, and will not \n\
117
-
be selected if the type becomes unknown."
118
-
|Name_out_of_scope (_, _, false) -> assertfalse
119
-
|Name_out_of_scope (ty, slist, true) ->
120
-
"this record of type "^ ty ^" contains fields that are \n\
121
-
not visible in the current scope: "
122
-
^String.concat "" slist ^".\n\
123
-
They will not be selected if the type becomes unknown."
124
-
|Ambiguous_name ([s], tl, false) ->
125
-
s ^" belongs to several types: "^String.concat "" tl ^
126
-
"\nThe first one was selected. Please disambiguate if this is wrong."
127
-
|Ambiguous_name (_, _, false) -> assertfalse
128
-
|Ambiguous_name (slist, tl, true) ->
129
-
"these field labels belong to several types: "^
130
-
String.concat "" tl ^
131
-
"\nThe first one was selected. Please disambiguate if this is wrong."
132
-
|Disambiguated_names ->
133
-
"this use of "^ s ^" required disambiguation."
134
-
|Nonoptional_labels ->
135
-
"the label "^ s ^" is not optional."
136
-
|Open_shadow_identifier (kind, s) ->
137
-
Printf.sprintf
138
-
"this open statement shadows the %s identifier %s (which is later used)"
139
-
kind s
140
-
|Open_shadow_label_constructor (kind, s) ->
141
-
Printf.sprintf
142
-
"this open statement shadows the %s %s (which is later used)"
143
-
kind s
144
-
|Bad_env_variable (var, s) ->
145
-
Printf.sprintf "illegal environment variable %s : %s" var s
146
-
|Attribute_payload (a, s) ->
147
-
Printf.sprintf "illegal payload for attribute '%s'.\n%s" a s
148
-
|Eliminated_optional_argumentssl ->
149
-
Printf.sprintf "implicit elimination of optional argument%s %s"
150
-
(ifList.length sl =1then""else"s")
151
-
(String.concat ", " sl)
152
-
|No_cmi_files ->
153
-
"no cmi file was found in path for module "^ s
154
-
|Bad_docstringunattached ->
155
-
if unattached then"unattached documentation comment (ignored)"
0 commit comments