Skip to content

Commit

Permalink
fix(compiler): Remove existing exports when writing universal exports (
Browse files Browse the repository at this point in the history
…grain-lang#919)

* fix(compiler): Remove existing exports when writing universal exports

* Actual test repro
  • Loading branch information
ospencer authored Sep 23, 2021
1 parent fce05c1 commit e80de43
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
2 changes: 2 additions & 0 deletions compiler/src/codegen/comp_utils.re
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ let write_universal_exports =
[||],
function_body,
);
// Remove existing Grain export (if any)
Export.remove_export(wasm_mod, name);
ignore @@ Export.add_function_export(wasm_mod, name, name);
| TSigValue(_)
| TSigType(_)
Expand Down
25 changes: 20 additions & 5 deletions compiler/test/input/wasiPolyfill.gr
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
import foreign wasm fd_write : (WasmI32, WasmI32, WasmI32, WasmI32) -> WasmI32 from "wasi_snapshot_preview1"
import foreign wasm fd_write: (
WasmI32,
WasmI32,
WasmI32,
WasmI32
) -> WasmI32 from "wasi_snapshot_preview1"

export let fd_write: (WasmI32, WasmI32, WasmI32, WasmI32) -> WasmI32 = (fd, iovs, iovs_len, nwritten) => {
fd_write(fd, iovs, iovs_len, nwritten)
fd_write(fd, iovs, iovs_len, nwritten)
fd_write(fd, iovs, iovs_len, nwritten)
export let fd_write: (WasmI32, WasmI32, WasmI32, WasmI32) -> WasmI32 =
(
fd,
iovs,
iovs_len,
nwritten,
) => {
fd_write(fd, iovs, iovs_len, nwritten)
fd_write(fd, iovs, iovs_len, nwritten)
fd_write(fd, iovs, iovs_len, nwritten)
}

export let args_get = (a, b) => {
76n
}

0 comments on commit e80de43

Please sign in to comment.