Bug dans direct_apply si l'expression de fonction a des effets et la fonction correspondante n'est pas close

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@1912 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Xavier Leroy 1998-04-08 11:35:20 +00:00
parent d22b828639
commit 077c8f688d
1 changed files with 8 additions and 1 deletions

View File

@ -177,7 +177,14 @@ let direct_apply fundesc funct ufunct uargs =
List.fold_right2
(fun param arg body -> Ulet(param, arg, body))
params app_args body in
(if is_pure funct then app else Usequence(ufunct, app))
(* If ufunct can contain side-effects or function definitions,
we must make sure that it is evaluated exactly once.
If the function is not closed, we evaluate ufunct as part of the
arguments.
If the function is closed, we force the evaluation of ufunct first. *)
if not fundesc.fun_closed || is_pure funct
then app
else Usequence(ufunct, app)
(* Maintain the approximation of the global structure being defined *)