Skip to content

Commit 90456a3

Browse files
committed
Compiler: fix closure generation
1 parent 3d59826 commit 90456a3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

compiler/generate_closure.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,11 @@ let f ((pc, blocks, free_pc) as p) : Code.program =
270270
let new_pc = free_pc in
271271
let free_pc = free_pc + 1 in
272272
let closure = Code.Var.fork x in
273+
let new_x = Code.Var.fork x in
273274
let args = List.map Code.Var.fork vars in
274275
let mapping =
275276
Jsoo_subst.from_map
276-
(Jsoo_subst.build_mapping vars args)
277+
(Jsoo_subst.build_mapping (x :: vars) (new_x :: args))
277278
in
278279
rewrite_list := (mapping, pc) :: !rewrite_list;
279280
let body_rev =
@@ -282,11 +283,10 @@ let f ((pc, blocks, free_pc) as p) : Code.program =
282283
:: body_rev
283284
in
284285
let new_block =
285-
let x = Code.Var.fork x in
286286
{ params = [];
287287
handler = None;
288-
body = [Let (x, Closure (params, (pc, List.map mapping pc_args)))];
289-
branch = Return x }
288+
body = [Let (new_x, Closure (params, (pc, List.map mapping pc_args)))];
289+
branch = Return new_x }
290290
in
291291
let blocks = AddrMap.add new_pc new_block blocks in
292292
body_rev, blocks, free_pc

0 commit comments

Comments
 (0)