Skip to content

Commit

Permalink
Improve error message for unfound lib:... globrefs
Browse files Browse the repository at this point in the history
  • Loading branch information
proux01 authored and gares committed Jan 27, 2024
1 parent 69952aa commit 7641839
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/coq_elpi_vernacular_syntax.mlg
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ let warning_legacy_accumulate_gen =
let warning_legacy_accumulate ?loc () = warning_legacy_accumulate_gen ?loc true
let warning_legacy_accumulate2 ?loc () = warning_legacy_accumulate_gen ?loc false

let lib_ref id =
let id = String.concat "." (snd id) in
try Coqlib.lib_ref id
with Coqlib.NotFoundRef _ ->
CErrors.user_err
Pp.(str "Global reference not found: lib:" ++ str id
++ str " (you may need to require some .v file with \
`Register ... as " ++ str id ++ str ".`).")

}
GRAMMAR EXTEND Gram
GLOBAL: term;
Expand All @@ -84,11 +93,11 @@ GRAMMAR EXTEND Gram

term: LEVEL "0"
[ [ "lib"; ":"; id = qualified_name -> {
let ref = Coqlib.lib_ref (String.concat "." (snd id)) in
let ref = lib_ref id in
let path = Nametab.path_of_global ref in
CAst.make ~loc Constrexpr.(CRef (Libnames.qualid_of_path ~loc:(fst id) path,None)) }
| "lib"; ":"; "@"; id = qualified_name -> {
let ref = Coqlib.lib_ref (String.concat "." (snd id)) in
let ref = lib_ref id in
let path = Nametab.path_of_global ref in
let f = Libnames.qualid_of_path ~loc:(fst id) path in
CAst.make ~loc Constrexpr.(CAppExpl((f,None),[])) } ] ]
Expand Down

0 comments on commit 7641839

Please sign in to comment.