From ffebade4b474be2b14117fe92d3ca72813d2d938 Mon Sep 17 00:00:00 2001 From: Gaƫtan Gilbert Date: Wed, 14 Oct 2020 16:54:49 +0200 Subject: Fix anomaly when importing a functor Fix #13162 --- test-suite/bugs/closed/bug_13162.v | 7 +++++++ vernac/vernacentries.ml | 10 ++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 test-suite/bugs/closed/bug_13162.v diff --git a/test-suite/bugs/closed/bug_13162.v b/test-suite/bugs/closed/bug_13162.v new file mode 100644 index 0000000000..eacc8980a9 --- /dev/null +++ b/test-suite/bugs/closed/bug_13162.v @@ -0,0 +1,7 @@ + +Module Type T. End T. +Module F (X:T). End F. +Fail Import F. +(* Error: Anomaly "Uncaught exception Not_found." *) + +Fail Import T. diff --git a/vernac/vernacentries.ml b/vernac/vernacentries.ml index 0d3f38d139..b125a86636 100644 --- a/vernac/vernacentries.ml +++ b/vernac/vernacentries.ml @@ -957,9 +957,15 @@ let interp_filter_in m = function let vernac_import export refl = let import_mod (qid,f) = - let m = try Nametab.locate_module qid + let loc = qid.loc in + let m = try + let m = Nametab.locate_module qid in + let () = if Modops.is_functor (Global.lookup_module m).Declarations.mod_type + then CErrors.user_err ?loc Pp.(str "Cannot import functor " ++ pr_qualid qid ++ str".") + in + m with Not_found -> - CErrors.user_err Pp.(str "Cannot find module " ++ pr_qualid qid) + CErrors.user_err ?loc Pp.(str "Cannot find module " ++ pr_qualid qid) in let f = interp_filter_in m f in Declaremods.import_module f ~export m -- cgit v1.2.3