From a9026275399a891d47f0d10f624a783a1afea05d Mon Sep 17 00:00:00 2001 From: Maxime Dénès Date: Fri, 23 Jan 2015 17:31:52 +0100 Subject: Fix previous commit on extraction. Since name clashes are discovered by side effects, the order of traversal of module structs cannot be changed. --- plugins/extraction/ocaml.ml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'plugins/extraction/ocaml.ml') diff --git a/plugins/extraction/ocaml.ml b/plugins/extraction/ocaml.ml index ce88ea6d2..85f18a093 100644 --- a/plugins/extraction/ocaml.ml +++ b/plugins/extraction/ocaml.ml @@ -634,10 +634,12 @@ and pp_module_type params = function str "functor (" ++ name ++ str ":" ++ typ ++ str ") ->" ++ fnl () ++ def | MTsig (mp, sign) -> push_visible mp params; - let try_pp_specif x l = + let try_pp_specif l x = try pp_specif x :: l with Failure "empty phrase" -> l in - let l = List.fold_right try_pp_specif sign [] in + (* We cannot use fold_right here due to side effects in pp_specif *) + let l = List.fold_left try_pp_specif [] sign in + let l = List.rev l in pop_visible (); str "sig " ++ fnl () ++ v 1 (str " " ++ prlist_with_sep fnl2 identity l) ++ @@ -710,10 +712,12 @@ and pp_module_expr params = function str "functor (" ++ name ++ str ":" ++ typ ++ str ") ->" ++ fnl () ++ def | MEstruct (mp, sel) -> push_visible mp params; - let try_pp_structure_elem x l = + let try_pp_structure_elem l x = try pp_structure_elem x :: l with Failure "empty phrase" -> l in - let l = List.fold_right try_pp_structure_elem sel [] in + (* We cannot use fold_right here due to side effects in pp_structure_elem *) + let l = List.fold_left try_pp_structure_elem [] sel in + let l = List.rev l in pop_visible (); str "struct " ++ fnl () ++ v 1 (str " " ++ prlist_with_sep fnl2 identity l) ++ -- cgit v1.2.3