Skip to content

Commit 26c180b

Browse files
committed
coq.env.dependencies don't include the root
1 parent 6d5090f commit 26c180b

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

src/coq_elpi_builtins.ml

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,7 @@ let dep1 ?inside sigma gr =
11211121
if ModPath.equal (modpath_of_gref x) modpath
11221122
then GRSet.add x acc
11231123
else acc in
1124+
<<<<<<< HEAD
11241125
let add acc t = grefs_of_term sigma (EConstr.of_constr t) add_if_inside acc in
11251126
match gr with
11261127
| VarRef id ->
@@ -1145,6 +1146,41 @@ let dep1 ?inside sigma gr =
11451146
let _, indbody = Global.lookup_inductive i in
11461147
let l = indbody.Declarations.mind_user_lc in
11471148
CArray.fold_left add GRSet.empty l
1149+
=======
1150+
let rec add acc c =
1151+
let open Constr in
1152+
match kind c with
1153+
| Var x -> add_if_inside (VarRef x) acc
1154+
| Const (c,_) -> add_if_inside (ConstRef c) acc
1155+
| Ind (i,_) -> add_if_inside (IndRef i) acc
1156+
| Construct (k,_) -> add_if_inside (ConstructRef k) acc
1157+
| _ -> Constr.fold add acc c
1158+
in
1159+
GRSet.remove gr @@
1160+
match gr with
1161+
| VarRef id ->
1162+
let decl = Environ.lookup_named id (Global.env()) in
1163+
let ty = Context.Named.Declaration.get_type decl in
1164+
let bo = Context.Named.Declaration.get_value decl in
1165+
let l =
1166+
match bo with
1167+
| None -> [ty]
1168+
| Some bo -> [ty; bo] in
1169+
List.fold_left add GRSet.empty l
1170+
| ConstRef cst ->
1171+
let cb = Environ.lookup_constant cst (Global.env()) in
1172+
let ty = cb.Declarations.const_type in
1173+
let bo = Global.body_of_constant_body Library.indirect_accessor cb in
1174+
let l =
1175+
match bo with
1176+
| Some (e,_,_) -> [ty; e]
1177+
| None -> [ty] in
1178+
List.fold_left add GRSet.empty l
1179+
| IndRef i | ConstructRef (i,_) ->
1180+
let _, indbody = Global.lookup_inductive i in
1181+
let l = indbody.Declarations.mind_user_lc in
1182+
CArray.fold_left add GRSet.empty l
1183+
>>>>>>> coq.env.dependencies don't include the root
11481184

11491185
let universe_level_set, universe_level_set_decl =
11501186
B.ocaml_set_conv ~name:"coq.univ.variable.set" universe_level_variable (module UnivLevelSet)
@@ -1688,7 +1724,7 @@ Supported attributes:
16881724
In(B.unspec modpath, "MP",
16891725
Out(gref_set, "Deps",
16901726
Read(unit_ctx, "Computes the transitive dependencies of GR. If MP is given, Deps only contains grefs from that module")))),
1691-
(fun roots inside _ ~depth _ _ state ->
1727+
(fun root inside _ ~depth _ _ state ->
16921728
let inside = unspec2opt inside in
16931729
let sigma = get_sigma state in
16941730
let rec aux seen = function
@@ -1703,6 +1739,7 @@ Supported attributes:
17031739
let seen = GRSet.add x seen in
17041740
aux seen (deps :: s :: rest)
17051741
in
1742+
<<<<<<< HEAD
17061743
!: (aux GRSet.empty [dep1 ?inside sigma roots]))),
17071744
DocAbove);
17081745

@@ -1714,6 +1751,9 @@ Supported attributes:
17141751
let sigma = get_sigma state in
17151752
let s = grefs_of_term sigma t GRSet.add GRSet.empty in
17161753
state, !: s, [])),
1754+
=======
1755+
!: (GRSet.remove root @@ aux GRSet.empty [dep1 ?inside root]))),
1756+
>>>>>>> coq.env.dependencies don't include the root
17171757
DocAbove);
17181758

17191759
MLCode(Pred("coq.env.current-path",

0 commit comments

Comments
 (0)