diff options
author | Maxime Dénès <mail@maximedenes.fr> | 2015-01-23 17:31:52 +0100 |
---|---|---|
committer | Maxime Dénès <mail@maximedenes.fr> | 2015-01-23 19:26:45 +0100 |
commit | a9026275399a891d47f0d10f624a783a1afea05d (patch) | |
tree | f0b6f30cb0a5e47a25bf66a0328bfad7545c61e8 /plugins/extraction | |
parent | c930010fc53531784485d5a190f9c0aeba1dfdbe (diff) |
Fix previous commit on extraction.
Since name clashes are discovered by side effects, the order of traversal of
module structs cannot be changed.
Diffstat (limited to 'plugins/extraction')
-rw-r--r-- | plugins/extraction/ocaml.ml | 12 |
1 files changed, 8 insertions, 4 deletions
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) ++ |