Skip to content

Commit 4bbf233

Browse files
committed
improve warning
1 parent 4a2039a commit 4bbf233

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/coq_elpi_utils.ml

+8-2
Original file line numberDiff line numberDiff line change
@@ -125,20 +125,26 @@ let elpi_cat = CWarnings.create_category ~name:"elpi" ()
125125

126126
let elpi_depr_cat =
127127
CWarnings.create_category ~from:[ elpi_cat; CWarnings.CoreCategories.deprecated ] ~name:"elpi.deprecated" ()
128-
128+
let elpi_tc_cat =
129+
CWarnings.create_category ~from:[ elpi_cat ] ~name:"elpi.typecheck" ()
130+
129131
let () = API.Setup.set_error (fun ?loc s -> err ?loc Pp.(str s))
130132
let () = API.Setup.set_anomaly (fun ?loc s -> err ?loc Pp.(str s))
131133
let () = API.Setup.set_type_error (fun ?loc s -> err ?loc Pp.(str s))
132134
let warn = CWarnings.create ~name:"elpi.runtime" ~category:elpi_cat (fun x -> x)
133135
let warn_impl = CWarnings.create ~name:"elpi.implication-precedence" ~category:elpi_cat (fun x -> x)
134136
let warn_impl_rex = Re.Str.regexp_string "The standard λProlog infix operator for implication"
135-
let warn_linear = CWarnings.create ~name:"elpi.linear-variable" ~category:elpi_cat (fun x -> x)
137+
let warn_linear = CWarnings.create ~name:"elpi.linear-variable" ~category:elpi_tc_cat (fun x -> x)
136138
let warn_linear_rex = Re.Str.regexp ".*is linear:.*discard.*fresh variable"
139+
let warn_missing_types = CWarnings.create ~name:"elpi.missing-types" ~category:elpi_tc_cat (fun x -> x)
140+
let warn_missing_types_rex = Re.Str.regexp_string "Undeclared globals"
141+
137142
let () = API.Setup.set_warn (fun ?loc x ->
138143
let loc = Option.map to_coq_loc loc in
139144
let msg = Pp.(hv 0 (Option.cata (fun loc -> Loc.pr loc ++ spc ()) (mt()) loc ++ str x)) in
140145
if Re.Str.string_match warn_impl_rex x 0 then warn_impl ?loc msg
141146
else if Re.Str.string_match warn_linear_rex x 0 then warn_linear ?loc msg
147+
else if Re.Str.string_match warn_missing_types_rex x 0 then warn_missing_types ?loc msg
142148
else warn ?loc msg)
143149
let () = API.Setup.set_std_formatter (Format.make_formatter feedback_fmt_write feedback_fmt_flush)
144150
let () = API.Setup.set_err_formatter (Format.make_formatter feedback_fmt_write feedback_fmt_flush)

0 commit comments

Comments
 (0)