aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaëtan Gilbert2020-10-14 16:54:49 +0200
committerGaëtan Gilbert2020-10-14 16:55:28 +0200
commitffebade4b474be2b14117fe92d3ca72813d2d938 (patch)
treed576ed6c0189104252a30d8725a9f2f171959a03
parent411025844a4c005ce03d77c6c640807c28269d4a (diff)
Fix anomaly when importing a functor
Fix #13162
-rw-r--r--test-suite/bugs/closed/bug_13162.v7
-rw-r--r--vernac/vernacentries.ml10
2 files changed, 15 insertions, 2 deletions
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