Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/ecCoreModules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,9 @@ type top_module_expr = {
tme_loca : locality;
}

let is_me_body_alias (body : module_body) =
match body with ME_Alias _ -> true | _ -> false

(* -------------------------------------------------------------------- *)
let ur_hash = EcAst.ur_hash

Expand Down
2 changes: 2 additions & 0 deletions src/ecCoreModules.mli
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ type top_module_expr = {
tme_loca : locality;
}

val is_me_body_alias : module_body -> bool

(* -------------------------------------------------------------------- *)
val mty_equal :
module_type ->
Expand Down
34 changes: 20 additions & 14 deletions src/ecSection.ml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ let pp_cbarg env fmt (who : cbarg) =
| `Module mp ->
let ppe =
match mp.m_top with
| `Local id -> EcPrinting.PPEnv.add_locals ppe [id]
| `Local id ->
if EcEnv.Mod.is_declared id env then
ppe
else EcPrinting.PPEnv.add_locals ppe [id]
| _ -> ppe in
Format.fprintf fmt "module %a" (EcPrinting.pp_topmod ppe) mp
| `ModuleType p ->
Expand Down Expand Up @@ -152,7 +155,7 @@ and on_ty (aenv : aenv) (ty : ty) =
match ty.ty_node with
| Tunivar _ -> ()
| Tvar _ -> ()
| Tglob _ -> ()
| Tglob m -> aenv.cb (`Module (mident m))
| Ttuple tys -> List.iter (on_ty aenv) tys
| Tconstr (p, tys) -> aenv.cb (`Type p); List.iter (on_ty aenv) tys
| Tfun (ty1, ty2) -> List.iter (on_ty aenv) [ty1; ty2]
Expand Down Expand Up @@ -370,10 +373,10 @@ and on_module (aenv : aenv) (me : module_expr) =

(* -------------------------------------------------------------------- *)
and on_mstruct (aenv : aenv) (st : module_structure) =
List.iter (on_mpath_mstruct1 aenv) st.ms_body
List.iter (on_mstruct1 aenv) st.ms_body

(* -------------------------------------------------------------------- *)
and on_mpath_mstruct1 (aenv : aenv) (item : module_item) =
and on_mstruct1 (aenv : aenv) (item : module_item) =
match item with
| MI_Module me -> on_module aenv me
| MI_Variable x -> on_ty aenv x.v_type
Expand Down Expand Up @@ -568,15 +571,16 @@ let pp_thname scenv =
(* -------------------------------------------------------------------- *)
let locality (env : EcEnv.env) (who : cbarg) =
match who with
| `Type p -> (EcEnv. Ty.by_path p env).tyd_loca
| `Op p -> (EcEnv. Op.by_path p env).op_loca
| `Ax p -> (EcEnv. Ax.by_path p env).ax_loca
| `Typeclass p -> ((EcEnv.TypeClass.by_path p env).tc_loca :> locality)
| `Module mp ->
begin match EcEnv.Mod.by_mpath_opt mp env with
| `Type p -> (EcEnv.Ty.by_path p env).tyd_loca
| `Op p -> (EcEnv.Op.by_path p env).op_loca
| `Ax p -> (EcEnv.Ax.by_path p env).ax_loca
| `Typeclass p -> ((EcEnv.TypeClass.by_path p env).tc_loca :> locality)
| `Module mp -> begin
match EcEnv.Mod.by_mpath_opt mp env with
| Some (_, Some lc) -> lc
(* in this case it should be a quantified module *)
| _ -> `Global
| _ ->
let id = EcPath.mget_ident mp in
if EcEnv.Mod.is_declared id env then `Declare else `Global
end
| `ModuleType p -> ((EcEnv.ModTy.by_path p env).tms_loca :> locality)
| `Instance _ -> assert false
Expand Down Expand Up @@ -1322,17 +1326,19 @@ let check_module scenv prefix tme =
match tme.tme_loca with
| `Local -> check_section scenv from
| `Global ->
if scenv.sc_insec then
if scenv.sc_insec then begin
let isalias = EcModules.is_me_body_alias tme.tme_expr.me_body in
let cd =
{ d_ty = [`Global];
d_op = [`Global];
d_ax = [];
d_sc = [];
d_mod = [`Global]; (* FIXME section: add local *)
d_mod = [`Global] @ (if isalias then [`Declare] else []);
d_modty = [`Global];
d_tc = [`Global];
} in
on_module (mkaenv scenv.sc_env (cb scenv from cd)) me
end
| `Declare -> (* Should be SC_decl_mod ... *)
assert false

Expand Down