mirror of
https://github.com/CatalaLang/catala.git
synced 2024-09-19 16:28:12 +03:00
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:
parent
bcde10242f
commit
c58e76f4e5
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user