diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 1998-04-08 11:35:20 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 1998-04-08 11:35:20 +0000 |
commit | 077c8f688d23f1f9a08045326fb8ac35f43a1a47 (patch) | |
tree | 38b1b5be88d018da06dfc39847a85538df8f2730 | |
parent | d22b8286397c32ee64c68bd0f8b4e075fa6c31e6 (diff) |
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
-rw-r--r-- | asmcomp/closure.ml | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/asmcomp/closure.ml b/asmcomp/closure.ml index 6914caad8..e435a0f2f 100644 --- a/asmcomp/closure.ml +++ b/asmcomp/closure.ml @@ -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 *) |