Skip to content

Commit 7641839

Browse files
proux01gares
authored andcommitted
Improve error message for unfound lib:... globrefs
1 parent 69952aa commit 7641839

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/coq_elpi_vernacular_syntax.mlg

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ let warning_legacy_accumulate_gen =
5959
let warning_legacy_accumulate ?loc () = warning_legacy_accumulate_gen ?loc true
6060
let warning_legacy_accumulate2 ?loc () = warning_legacy_accumulate_gen ?loc false
6161

62+
let lib_ref id =
63+
let id = String.concat "." (snd id) in
64+
try Coqlib.lib_ref id
65+
with Coqlib.NotFoundRef _ ->
66+
CErrors.user_err
67+
Pp.(str "Global reference not found: lib:" ++ str id
68+
++ str " (you may need to require some .v file with \
69+
`Register ... as " ++ str id ++ str ".`).")
70+
6271
}
6372
GRAMMAR EXTEND Gram
6473
GLOBAL: term;
@@ -84,11 +93,11 @@ GRAMMAR EXTEND Gram
8493

8594
term: LEVEL "0"
8695
[ [ "lib"; ":"; id = qualified_name -> {
87-
let ref = Coqlib.lib_ref (String.concat "." (snd id)) in
96+
let ref = lib_ref id in
8897
let path = Nametab.path_of_global ref in
8998
CAst.make ~loc Constrexpr.(CRef (Libnames.qualid_of_path ~loc:(fst id) path,None)) }
9099
| "lib"; ":"; "@"; id = qualified_name -> {
91-
let ref = Coqlib.lib_ref (String.concat "." (snd id)) in
100+
let ref = lib_ref id in
92101
let path = Nametab.path_of_global ref in
93102
let f = Libnames.qualid_of_path ~loc:(fst id) path in
94103
CAst.make ~loc Constrexpr.(CAppExpl((f,None),[])) } ] ]

0 commit comments

Comments
 (0)