Skip to content

Commit

Permalink
Merge pull request #40 from ocaml-wasm/fix-partial-app
Browse files Browse the repository at this point in the history
Partial application fix
  • Loading branch information
vouillon committed May 23, 2024
2 parents ef48ae6 + 9eb33a6 commit 6d4d2fc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
7 changes: 4 additions & 3 deletions compiler/lib/wasm/wa_generate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,10 @@ module Generate (Target : Wa_target_sig.S) = struct
match kind, funct with
| `Index, W.ConstSym (V g, 0) | `Ref _, W.RefFunc g ->
(* Functions with constant closures ignore their
environment *)
let* unit = Value.unit in
return (W.Call (g, List.rev (unit :: acc)))
environment. In case of partial application, we
still need the closure. *)
let* cl = if exact then Value.unit else return closure in
return (W.Call (g, List.rev (cl :: acc)))
| `Index, _ ->
return
(W.Call_indirect
Expand Down
13 changes: 13 additions & 0 deletions compiler/tests-wasm_of_ocaml/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(executables
(names gh38)
(modes js)
(js_of_ocaml (flags :standard --disable optcall)))

(rule
(target gh38.actual)
(enabled_if (= %{profile} wasm))
(alias runtest)
(action
(with-outputs-to
%{target}
(run node %{dep:gh38.bc.js}))))
3 changes: 3 additions & 0 deletions compiler/tests-wasm_of_ocaml/gh38.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
let f () () = ()

let (_ : _ -> _) = f ()

0 comments on commit 6d4d2fc

Please sign in to comment.