mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 07:51:43 +03:00
Fix: return module items in file order
This affects their UIDs, and the order in which they later get traversed. In particular, it was affecting the struct names renaming.
This commit is contained in:
parent
dbfd05155b
commit
acc13867bf
@ -122,6 +122,10 @@ let rename_ids
|
|||||||
let module PathMap = Map.Make (Uid.Path) in
|
let module PathMap = Map.Make (Uid.Path) in
|
||||||
let pctxmap = PathMap.singleton [] ctx in
|
let pctxmap = PathMap.singleton [] ctx in
|
||||||
let pctxmap, structs_map, fields_map, ctx_structs =
|
let pctxmap, structs_map, fields_map, ctx_structs =
|
||||||
|
(* Warning: the folding order matters here, if a module contains e.g. two
|
||||||
|
fields with the same name. This fold relies on UIDs, and is thus
|
||||||
|
dependent on the definition order. Another possibility would be to fold
|
||||||
|
lexicographically, but the result would be "less intuitive" *)
|
||||||
StructName.Map.fold
|
StructName.Map.fold
|
||||||
(fun name fields (pctxmap, structs_map, fields_map, ctx_structs) ->
|
(fun name fields (pctxmap, structs_map, fields_map, ctx_structs) ->
|
||||||
let path = StructName.path name in
|
let path = StructName.path name in
|
||||||
|
@ -476,7 +476,8 @@ let get_interface program =
|
|||||||
(* Non-metadata blocks are ignored *)
|
(* Non-metadata blocks are ignored *)
|
||||||
req, acc
|
req, acc
|
||||||
in
|
in
|
||||||
List.fold_left filter ([], []) program.Ast.program_items
|
let req, acc = List.fold_left filter ([], []) program.Ast.program_items in
|
||||||
|
List.rev req, List.rev acc
|
||||||
|
|
||||||
(** {1 API} *)
|
(** {1 API} *)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user