Skip to content

Commit fe73656

Browse files
committed
Tweak for evaluation order of labelled partial applications (#10653)
1 parent 0527570 commit fe73656

File tree

1 file changed

+8
-23
lines changed

1 file changed

+8
-23
lines changed

lambda/translcore.ml

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -764,10 +764,6 @@ and transl_apply ~scopes
764764
defs := (id, lam) :: !defs;
765765
Lvar id
766766
in
767-
let args, args' =
768-
if List.for_all (fun (_,opt) -> opt) args then [], args
769-
else args, []
770-
in
771767
let lam =
772768
if args = [] then lam else lapply lam (List.rev_map fst args)
773769
in
@@ -778,26 +774,15 @@ and transl_apply ~scopes
778774
let id_arg = Ident.create_local "param" in
779775
(* FIXME modes / Curried nlocals are completely wrong here *)
780776
let body =
781-
match build_apply handle ((Lvar id_arg, optional)::args') l with
782-
Lfunction{kind = Curried nl; params = ids; return;
783-
body = lam; attr; loc; mode=Alloc_heap; ret_mode} ->
784-
Lfunction{kind = Curried nl; (* FIXME *)
785-
params = (id_arg, Pgenval)::ids;
786-
return;
787-
body = lam; attr;
788-
loc;
789-
mode; (* FIXME mode *)
790-
ret_mode}
791-
| lam ->
792-
Lfunction{kind = Curried {nlocal=0}; params = [id_arg, Pgenval];
793-
return = Pgenval; body = lam;
794-
attr = default_stub_attribute; loc = loc;
795-
mode = Alloc_heap (* FIXME *);
796-
ret_mode = Alloc_heap (* FIXME wrong mode *)}
777+
let body = build_apply handle [Lvar id_arg, optional] l in
778+
Lfunction{kind = Curried {nlocal=0}; params = [id_arg, Pgenval];
779+
return = Pgenval; body; mode=Alloc_heap;
780+
ret_mode=Alloc_heap; attr = default_stub_attribute;
781+
loc = loc}
797782
in
798-
List.fold_left
799-
(fun body (id, lam) -> Llet(Strict, Pgenval, id, lam, body))
800-
body !defs
783+
List.fold_right
784+
(fun (id, lam) body -> Llet(Strict, Pgenval, id, lam, body))
785+
!defs body
801786
| (Some arg, optional) :: l ->
802787
build_apply lam ((arg, optional) :: args) l
803788
| [] ->

0 commit comments

Comments
 (0)