This commit is contained in:
Louis Gesbert 2023-10-03 18:50:18 +02:00
parent 263cf3a9f7
commit 2708fa53b2
4 changed files with 19 additions and 19 deletions

View File

@ -747,8 +747,8 @@ let test_cmd =
[
Nj.binding Var.post_test
[
"test_reset() { if ! diff -q $$1 $$2 >/dev/null; then cp -f $$2 $$1; \
fi; }";
"test_reset() { if ! diff -q $$1 $$2 >/dev/null; then cp -f \
$$2 $$1; fi; }";
";";
"test_reset";
];

View File

@ -483,7 +483,6 @@ let rec translate_expr
Message.raise_spanned_error (Mark.get s_name)
"This identifier should refer to a struct name"
in
let s_fields =
List.fold_left
(fun s_fields (f_name, f_e) ->

View File

@ -112,7 +112,9 @@ let detect_unused_struct_fields (p : program) : unit =
let rec structs_fields_used_expr e struct_fields_used =
match Mark.remove e with
| EDStructAccess { name_opt = Some name; e = e_struct; field } ->
let ctx = Program.module_ctx p.program_ctx (StructName.path name) in
let ctx =
Program.module_ctx p.program_ctx (StructName.path name)
in
let field =
StructName.Map.find name
(Ident.Map.find field ctx.ctx_struct_fields)

View File

@ -999,24 +999,23 @@ let form_context (prgm : Surface.Ast.program) : context =
ctxt prgm.program_items
in
let rec gather_all_constrs ctxt =
(* Gather struct fields and enum constrs from modules: this helps with disambiguation *)
(* Gather struct fields and enum constrs from modules: this helps with
disambiguation *)
let modules, constructor_idmap, field_idmap =
ModuleName.Map.fold
(fun m ctx (mmap, constrs, fields) ->
let ctx = gather_all_constrs ctx in
ModuleName.Map.add m ctx mmap,
Ident.Map.union
(fun _ enu1 enu2 ->
Some (EnumName.Map.union (fun _ _ -> assert false)
enu1 enu2))
constrs ctx.constructor_idmap,
Ident.Map.union
(fun _ str1 str2 ->
Some (StructName.Map.union (fun _ _ -> assert false)
str1 str2))
fields ctx.field_idmap
)
ctxt.modules (ModuleName.Map.empty, ctxt.constructor_idmap, ctxt.field_idmap)
let ctx = gather_all_constrs ctx in
( ModuleName.Map.add m ctx mmap,
Ident.Map.union
(fun _ enu1 enu2 ->
Some (EnumName.Map.union (fun _ _ -> assert false) enu1 enu2))
constrs ctx.constructor_idmap,
Ident.Map.union
(fun _ str1 str2 ->
Some (StructName.Map.union (fun _ _ -> assert false) str1 str2))
fields ctx.field_idmap ))
ctxt.modules
(ModuleName.Map.empty, ctxt.constructor_idmap, ctxt.field_idmap)
in
{ ctxt with modules; constructor_idmap; field_idmap }
in