aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorPierre-Marie Pédrot2015-01-25 18:05:10 +0100
committerPierre-Marie Pédrot2015-01-25 18:05:42 +0100
commit8434840413d7cef32ed83539a0c7ef4de13ec528 (patch)
treeb6ea2152ef16ce0953b889b2c2ad93c364e61e19 /plugins
parent4e515c483e41f0362bf1102f8e8ae071fdcf04f7 (diff)
parent3d6b9a7ab992559493b89e174549734dff401703 (diff)
Merge branch 'v8.5' into trunk.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/extraction/ocaml.ml12
1 files changed, 8 insertions, 4 deletions
diff --git a/plugins/extraction/ocaml.ml b/plugins/extraction/ocaml.ml
index ce88ea6d29..85f18a0933 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) ++