Gather the maps for subscope vars to the top level

(they use UIDs so this doesn't jeopardize proper name resolution ; and it allows
resolution of subscope calls without further code modifications)
This commit is contained in:
Louis Gesbert 2023-08-15 23:52:03 +02:00
parent bcde10242f
commit c58e76f4e5
2 changed files with 17 additions and 0 deletions

View File

@ -949,6 +949,16 @@ let form_context (prgm : Surface.Ast.program) : context =
List.fold_left import_module ModuleName.Map.empty prgm.program_modules
in
let ctxt = { empty_ctxt with modules } in
let rec gather_var_sigs acc modules =
(* Scope vars from imported modules need to be accessible directly for definitions through submodules *)
ModuleName.Map.fold (fun _modname mctx acc ->
let acc = gather_var_sigs acc mctx.modules in
ScopeVar.Map.union (fun _ _ -> assert false) acc mctx.var_typs)
modules acc
in
let ctxt =
{ ctxt with var_typs = gather_var_sigs ScopeVar.Map.empty ctxt.modules }
in
let ctxt =
List.fold_left
(process_law_structure process_name_item)

View File

@ -807,6 +807,13 @@ let translate_program
}
in
let ctx = make_ctx desugared in
let rec gather_scope_vars acc modules =
ModuleName.Map.fold (fun _modname mctx acc ->
let acc = gather_scope_vars acc mctx.modules in
ScopeVar.Map.union (fun _ _ -> assert false) acc mctx.scope_var_mapping)
modules acc
in
let ctx = { ctx with scope_var_mapping = gather_scope_vars ctx.scope_var_mapping ctx.modules } in
let rec process_decl_ctx ctx decl_ctx =
let ctx_scopes =
ScopeName.Map.map