From ee64a71f5e071b7fa0495847388c19d83bc5c9bd Mon Sep 17 00:00:00 2001 From: Gaƫtan Gilbert Date: Tue, 31 Mar 2020 15:21:40 +0200 Subject: Close #11935: section variables do not have universe instances. --- interp/constrintern.ml | 2 +- pretyping/pretyping.ml | 10 +++++++++- test-suite/bugs/closed/bug_11935.v | 6 ++++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 test-suite/bugs/closed/bug_11935.v diff --git a/interp/constrintern.ml b/interp/constrintern.ml index 905d9f1e5b..45255609e0 100644 --- a/interp/constrintern.ml +++ b/interp/constrintern.ml @@ -989,7 +989,7 @@ let string_of_ty = function | Variable -> "var" let gvar (loc, id) us = match us with -| None -> DAst.make ?loc @@ GVar id +| None | Some [] -> DAst.make ?loc @@ GVar id | Some _ -> user_err ?loc (str "Variable " ++ Id.print id ++ str " cannot have a universe instance") diff --git a/pretyping/pretyping.ml b/pretyping/pretyping.ml index 015c26531a..940150b15a 100644 --- a/pretyping/pretyping.ml +++ b/pretyping/pretyping.ml @@ -438,7 +438,15 @@ let pretype_ref ?loc sigma env ref us = match ref with | GlobRef.VarRef id -> (* Section variable *) - (try sigma, make_judge (mkVar id) (NamedDecl.get_type (lookup_named id !!env)) + (try + let ty = NamedDecl.get_type (lookup_named id !!env) in + (match us with + | None | Some [] -> () + | Some (_ :: _) -> + CErrors.user_err ?loc + Pp.(str "Section variables are not polymorphic:" ++ spc () + ++ str "universe instance should have length 0.")); + sigma, make_judge (mkVar id) ty with Not_found -> (* This may happen if env is a goal env and section variables have been cleared - section variables should be different from goal diff --git a/test-suite/bugs/closed/bug_11935.v b/test-suite/bugs/closed/bug_11935.v new file mode 100644 index 0000000000..ad5ffc68b5 --- /dev/null +++ b/test-suite/bugs/closed/bug_11935.v @@ -0,0 +1,6 @@ +Section S. + Variable A : Prop. + + Fail Check A@{Type}. + Check A@{}. +End S. -- cgit v1.2.3