WebAssembly / esm-integration

ECMAScript module integration
https://webassembly.github.io/esm-integration/js-api/index.html#esm-integration
Other
378 stars 32 forks source link

function's result type without `return` #66

Closed yviansu closed 1 year ago

yviansu commented 2 years ago

In the example of wasm imports <- wasm exports, the exported function increment in counter.wasm has no return value, when importing function increment in main.wasm, why setting the function's result type is i32?

;; main.wat --> main.wasm
(module
  (import "./counter.wasm" "count" (global i32))
  (import "./counter.wasm" "increment" (func $increment (result i32)))
)

;; counter.wat --> counter.wasm
(module
  (func (export "increment")
    (global.set 0
      (i32.add
        (global.get 0)
        (i32.const 1))))
  (global (export "count") (mut i32) i32.const 5)
)
ghost commented 2 years ago

That seems like nothing more than an err on part of the author - I'll review and report back, or make a PR.