Skip to content

Commit 8e0c142

Browse files
committed
When doing section-analysis, recurse in types body
1 parent 2a9d76e commit 8e0c142

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/ecSection.ml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,13 @@ type aenv = {
9898
}
9999

100100
and acache = {
101-
op : Sp.t; (* Operator declaration already handled *)
101+
op : Sp.t; (* Operator declaration already handled *)
102+
type_ : Sp.t; (* Type declaration already handled *)
102103
}
103104

104105
(* -------------------------------------------------------------------- *)
105106
let empty_acache : acache =
106-
{ op = Sp.empty; }
107+
{ op = Sp.empty; type_ = Sp.empty; }
107108

108109
(* -------------------------------------------------------------------- *)
109110
let mkaenv (env : EcEnv.env) (cb : cb) : aenv =
@@ -154,9 +155,18 @@ and on_ty (aenv : aenv) (ty : ty) =
154155
| Tvar _ -> ()
155156
| Tglob _ -> ()
156157
| Ttuple tys -> List.iter (on_ty aenv) tys
157-
| Tconstr (p, tys) -> aenv.cb (`Type p); List.iter (on_ty aenv) tys
158+
| Tconstr (p, tys) -> on_tyname aenv p; List.iter (on_ty aenv) tys
158159
| Tfun (ty1, ty2) -> List.iter (on_ty aenv) [ty1; ty2]
159160

161+
(* -------------------------------------------------------------------- *)
162+
and on_tyname (aenv : aenv) (p : path) =
163+
aenv.cb (`Type p);
164+
if not (Sp.mem p !(aenv.cache).type_) then begin
165+
let cache = { !(aenv.cache) with type_ = Sp.add p !(aenv.cache).type_ } in
166+
aenv.cache := cache;
167+
on_tydecl aenv (EcEnv.Ty.by_path p aenv.env)
168+
end
169+
160170
(* -------------------------------------------------------------------- *)
161171
and on_opname (aenv : aenv) (p : EcPath.path) =
162172
aenv.cb (`Op p);

0 commit comments

Comments
 (0)