From bd755284f3fcdf7f2fced477b81d64d72226a38f Mon Sep 17 00:00:00 2001 From: Matthieu Sozeau Date: Tue, 17 Jun 2014 16:49:12 +0200 Subject: Continue fix on argument scopes of primitive projections. --- interp/constrintern.ml | 26 +++++++----- test-suite/bugs/closed/HoTT_coq_085.v | 74 +++++++++++++++++++++++++++++++++++ test-suite/bugs/opened/HoTT_coq_085.v | 74 ----------------------------------- 3 files changed, 91 insertions(+), 83 deletions(-) create mode 100644 test-suite/bugs/closed/HoTT_coq_085.v delete mode 100644 test-suite/bugs/opened/HoTT_coq_085.v diff --git a/interp/constrintern.ml b/interp/constrintern.ml index dc1db3c2b9..d9f0573119 100644 --- a/interp/constrintern.ml +++ b/interp/constrintern.ml @@ -681,7 +681,11 @@ let intern_var genv (ltacvars,ntnvars) namedctx loc id = GVar (loc,id), [], [], [] let is_projection_ref = function - | ConstRef r -> if Environ.is_projection r (Global.env ()) then Some r else None + | ConstRef r -> + if Environ.is_projection r (Global.env ()) then + let pb = Environ.lookup_projection r (Global.env ()) in + Some (r, pb.Declarations.proj_npars) + else None | _ -> None let proj_impls r impls = @@ -689,28 +693,32 @@ let proj_impls r impls = let f (x, l) = x, projection_implicits env r l in List.map f impls +let proj_scopes n scopes = + List.skipn_at_least n scopes + let find_appl_head_data c = match c with | GRef (loc,ref,_) as x -> let impls = implicits_of_global ref in - let isproj, impls = + let scopes = find_arguments_scope ref in + let isproj, impls, scopes = match is_projection_ref ref with - | Some r -> true, proj_impls r impls - | None -> false, impls + | Some (r, n) -> true, proj_impls r impls, proj_scopes n scopes + | None -> false, impls, scopes in - let scopes = find_arguments_scope ref in x, isproj, impls, scopes, [] | GApp (_,GRef (_,ref,_),l) as x when l != [] && Flags.version_strictly_greater Flags.V8_2 -> let n = List.length l in let impls = implicits_of_global ref in - let isproj, impls = + let scopes = find_arguments_scope ref in + let isproj, impls, scopes = match is_projection_ref ref with - | Some r -> true, proj_impls r impls - | None -> false, impls + | Some (r, n) -> true, proj_impls r impls, proj_scopes n scopes + | None -> false, impls, scopes in x, isproj, List.map (drop_first_implicits n) impls, - List.skipn_at_least n (find_arguments_scope ref),[] + List.skipn_at_least n scopes,[] | x -> x,false,[],[],[] let error_not_enough_arguments loc = diff --git a/test-suite/bugs/closed/HoTT_coq_085.v b/test-suite/bugs/closed/HoTT_coq_085.v new file mode 100644 index 0000000000..041c67997f --- /dev/null +++ b/test-suite/bugs/closed/HoTT_coq_085.v @@ -0,0 +1,74 @@ +Set Implicit Arguments. +Set Universe Polymorphism. + +Module success. + Unset Primitive Projections. + + Record category := + { ob : Type; + hom : ob -> ob -> Type; + comp : forall x y z, hom y z -> hom x y -> hom x z }. + + Delimit Scope hom_scope with hom. + Bind Scope hom_scope with hom. + Arguments hom : clear implicits. + Arguments comp _ _ _ _ _%hom _%hom : clear implicits. + + Notation "f 'o' g" := (comp _ _ _ _ f g) (at level 40, left associativity) : hom_scope. + + Record functor (C D : category) := + { ob_of : ob C -> ob D; + hom_of : forall x y, hom C x y -> hom D (ob_of x) (ob_of y) }. + + Delimit Scope functor_scope with functor. + Bind Scope functor_scope with functor. + + Arguments hom_of _ _ _%functor _ _ _%hom. + + Notation "F '_1' m" := (hom_of F _ _ m) (at level 10, no associativity) : hom_scope. + + Axiom f_comp : forall C D E, functor D E -> functor C D -> functor C E. + Notation "f 'o' g" := (@f_comp _ _ _ f g) (at level 40, left associativity) : functor_scope. + + Check ((_ o _) _1 _)%hom. (* ((?16 o ?17) _1 ?20)%hom + : hom ?15 (ob_of (?16 o ?17) ?18) (ob_of (?16 o ?17) ?19) *) +End success. + +Module failure. + Set Primitive Projections. + + Record category := + { ob : Type; + hom : ob -> ob -> Type; + comp : forall x y z, hom y z -> hom x y -> hom x z }. + + Delimit Scope hom_scope with hom. + Bind Scope hom_scope with hom. + Arguments hom : clear implicits. + Arguments comp _ _ _ _ _%hom _%hom : clear implicits. + + Notation "f 'o' g" := (comp _ _ _ _ f g) (at level 40, left associativity) : hom_scope. + + Record functor (C D : category) := + { ob_of : ob C -> ob D; + hom_of : forall x y, hom C x y -> hom D (ob_of x) (ob_of y) }. + + Delimit Scope functor_scope with functor. + Bind Scope functor_scope with functor. + + Arguments hom_of _ _ _%functor _ _ _%hom. + + Notation "F '_1' m" := (hom_of F _ _ m) (at level 10, no associativity) : hom_scope. + Notation "F '_2' m" := (hom_of F%functor _ _ m) (at level 10, no associativity) : hom_scope. + + Axiom f_comp : forall C D E, functor D E -> functor C D -> functor C E. + Notation "f 'o' g" := (@f_comp _ _ _ f g) (at level 40, left associativity) : functor_scope. + + Check ((_ o _) _2 _)%hom. (* ((?14 o ?15)%functor _1 ?18)%hom + : hom ?13 (ob_of (?14 o ?15)%functor ?16) + (ob_of (?14 o ?15)%functor ?17) *) + Check ((_ o _) _1 _)%hom. (* Toplevel input, characters 7-19: +Error: +The term "(?23 o ?24)%hom" has type "hom ?19 ?20 ?22" +while it is expected to have type "functor ?25 ?26". *) +End failure. diff --git a/test-suite/bugs/opened/HoTT_coq_085.v b/test-suite/bugs/opened/HoTT_coq_085.v deleted file mode 100644 index 43ca6864f4..0000000000 --- a/test-suite/bugs/opened/HoTT_coq_085.v +++ /dev/null @@ -1,74 +0,0 @@ -Set Implicit Arguments. -Set Universe Polymorphism. - -Module success. - Unset Primitive Projections. - - Record category := - { ob : Type; - hom : ob -> ob -> Type; - comp : forall x y z, hom y z -> hom x y -> hom x z }. - - Delimit Scope hom_scope with hom. - Bind Scope hom_scope with hom. - Arguments hom : clear implicits. - Arguments comp _ _ _ _ _%hom _%hom : clear implicits. - - Notation "f 'o' g" := (comp _ _ _ _ f g) (at level 40, left associativity) : hom_scope. - - Record functor (C D : category) := - { ob_of : ob C -> ob D; - hom_of : forall x y, hom C x y -> hom D (ob_of x) (ob_of y) }. - - Delimit Scope functor_scope with functor. - Bind Scope functor_scope with functor. - - Arguments hom_of _ _ _%functor _ _ _%hom. - - Notation "F '_1' m" := (hom_of F _ _ m) (at level 10, no associativity) : hom_scope. - - Axiom f_comp : forall C D E, functor D E -> functor C D -> functor C E. - Notation "f 'o' g" := (@f_comp _ _ _ f g) (at level 40, left associativity) : functor_scope. - - Check ((_ o _) _1 _)%hom. (* ((?16 o ?17) _1 ?20)%hom - : hom ?15 (ob_of (?16 o ?17) ?18) (ob_of (?16 o ?17) ?19) *) -End success. - -Module failure. - Set Primitive Projections. - - Record category := - { ob : Type; - hom : ob -> ob -> Type; - comp : forall x y z, hom y z -> hom x y -> hom x z }. - - Delimit Scope hom_scope with hom. - Bind Scope hom_scope with hom. - Arguments hom : clear implicits. - Arguments comp _ _ _ _ _%hom _%hom : clear implicits. - - Notation "f 'o' g" := (comp _ _ _ _ f g) (at level 40, left associativity) : hom_scope. - - Record functor (C D : category) := - { ob_of : ob C -> ob D; - hom_of : forall x y, hom C x y -> hom D (ob_of x) (ob_of y) }. - - Delimit Scope functor_scope with functor. - Bind Scope functor_scope with functor. - - Arguments hom_of _ _ _%functor _ _ _%hom. - - Notation "F '_1' m" := (hom_of F _ _ m) (at level 10, no associativity) : hom_scope. - Notation "F '_2' m" := (hom_of F%functor _ _ m) (at level 10, no associativity) : hom_scope. - - Axiom f_comp : forall C D E, functor D E -> functor C D -> functor C E. - Notation "f 'o' g" := (@f_comp _ _ _ f g) (at level 40, left associativity) : functor_scope. - - Check ((_ o _) _2 _)%hom. (* ((?14 o ?15)%functor _1 ?18)%hom - : hom ?13 (ob_of (?14 o ?15)%functor ?16) - (ob_of (?14 o ?15)%functor ?17) *) - Fail Check ((_ o _) _1 _)%hom. (* Toplevel input, characters 7-19: -Error: -The term "(?23 o ?24)%hom" has type "hom ?19 ?20 ?22" -while it is expected to have type "functor ?25 ?26". *) -End failure. -- cgit v1.2.3