File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,11 @@ open Longident
26
26
27
27
let error ~loc msg = raise (Location. Error (Location. error ~loc msg))
28
28
29
+ let warn ~loc msg e =
30
+ let e_msg = Exp. constant (Const. string msg) in
31
+ let structure = {pstr_desc = Pstr_eval (e_msg, [] ); pstr_loc = loc} in
32
+ Exp. attr e ({txt = " ocaml.ppwarning" ; loc}, PStr [structure])
33
+
29
34
let dyn_bindings = ref []
30
35
let clear_bindings () = dyn_bindings := []
31
36
let add_binding binding = dyn_bindings := binding :: ! dyn_bindings
@@ -119,7 +124,8 @@ let transform_cases ~loc e cases =
119
124
let e0 = Exp. constant (Const. string pos.pos_fname) in
120
125
let e1 = Exp. constant (Const. int pos.pos_lnum) in
121
126
let e2 = Exp. constant (Const. int (pos.pos_cnum - pos.pos_bol)) in
122
- (cases, [% expr raise (Match_failure ([% e e0], [% e e1], [% e e2]))]))
127
+ let e = [% expr raise (Match_failure ([% e e0], [% e e1], [% e e2]))] in
128
+ (cases, warn ~loc " A universal case is recommended for %pcre." e))
123
129
in
124
130
let cases = List. rev_map aux cases in
125
131
let res = Exp. array (List. map (fun (re , _ , _ , _ ) -> re) cases) in
You can’t perform that action at this time.
0 commit comments