Skip to content

Wrong compilation of closures #856

Closed
@hhugo

Description

@hhugo

The following program raises but should not.
Fixed in js_of_ocaml by ocsigen/js_of_ocaml@90456a3

let () =
  let delayed = ref (fun () -> ()) in
  for i = 1 to 2 do
    let rec f n = function
      | 0 -> assert (i = n)
      | j -> delayed :=
         let prev = !delayed in
         (fun () -> prev (); f (succ n + i - i) (pred j))
    in f 0 i
  done;
  !delayed ();;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions