Skip to content

Commit 1c767a2

Browse files
committed
warning on hints immediate|external|unfold
1 parent 9ebf370 commit 1c767a2

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

apps/tc/_CoqProject.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
-arg -w -arg -Not-added
2+
-arg -w -arg -TC.hints
23

34
# Hack to see Coq-Elpi even if it is not installed yet
45
-Q ../../theories elpi

src/coq_elpi_builtins.ml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -535,18 +535,24 @@ let get_instance (env: Environ.env) (sigma: Evd.evar_map) (tc : GlobRef.t) (inst
535535
in
536536
instances_grefs2istance instance
537537

538+
let warning_tc_hints = CWarnings.create ~name:"TC.hints" ~category:elpi_cat Pp.str
539+
538540
let get_instances (env: Environ.env) (sigma: Evd.evar_map) tc : type_class_instance list =
539541
let hint_db = Hints.searchtable_map "typeclass_instances" in
540542
let secvars : Names.Id.Pred.t = Names.Id.Pred.full in
541543
let full_hints = Hints.Hint_db.map_all ~secvars:secvars tc hint_db in
542-
let hint_asts = List.map Hints.FullHint.repr full_hints in
543-
let hints = List.filter_map (function
544-
| Hints.Res_pf a -> Some a
545-
| ERes_pf a -> Some a
546-
| Extern (a, b) -> None
547-
| Give_exact a -> Some a
548-
| Res_pf_THEN_trivial_fail e -> Some e
549-
| Unfold_nth e -> None) hint_asts in
544+
(* let hint_asts = List.map Hints.FullHint.repr full_hints in *)
545+
let hints = List.filter_map (fun (e : Hints.FullHint.t) -> match Hints.FullHint.repr e with
546+
| Hints.Res_pf a | ERes_pf a | Give_exact a -> Some a (* Respectively Hint Apply | EApply | Exact *)
547+
| Extern _ ->
548+
warning_tc_hints (Printf.sprintf "There is an hint extern in the typeclass db: \n%s" (Pp.string_of_ppcmds @@ Hints.FullHint.print env sigma e));
549+
None
550+
| Res_pf_THEN_trivial_fail _ -> (* Hint Immediate *)
551+
warning_tc_hints (Printf.sprintf "There is an hint immediate in the typeclass db: \n%s" (Pp.string_of_ppcmds @@ Hints.FullHint.print env sigma e));
552+
None
553+
| Unfold_nth _ ->
554+
warning_tc_hints (Printf.sprintf "There is an hint unfold in the typeclass db: \n%s" (Pp.string_of_ppcmds @@ Hints.FullHint.print env sigma e));
555+
None) full_hints in
550556
let constrs = List.map (fun a -> Hints.hint_as_term a |> snd) hints in
551557
(* Printer.pr_global tc |> Pp.string_of_ppcmds |> Printf.printf "%s\n"; *)
552558
let instances_grefs = List.filter_map (fun e ->

0 commit comments

Comments
 (0)