`GetFunction` returns `func(...interface {}) (interface {}, error)` not `func() (string, error)`
alexec opened this issue · comments
Alex Collins commented
I don't understand why this is happening. I'm compiling this function:
//export getDocument
func getDocument() string {
return ""
}
Using this command
tinygo build -o ../module.wasm -wasm-abi=generic -target=wasi .
When I execute Exports.GetFunction("getDocument")
I get this signature func(...interface {}) (interface {}, error)
.
That is really weird to me.
If I add a single argument to
//export getDocument
func getDocument(arg string) string {
return ""
}
I now get a Missing 2 argument(s) when calling the function; Expected 3 argument(s), received 1
error.
What is going on, this makes no sense to me. Why has it suddenly gone from zero args to three args?
Alex Collins commented
Ok, so presumably this is a tinygo
bug.
wasmer inspect module.wasm
Type: wasm
Size: 269.0 KB
Imports:
Functions:
"wasi_snapshot_preview1"."fd_write": [I32, I32, I32, I32] -> [I32]
"wasi_snapshot_preview1"."clock_time_get": [I32, I64, I32] -> [I32]
"wasi_snapshot_preview1"."args_sizes_get": [I32, I32] -> [I32]
"wasi_snapshot_preview1"."args_get": [I32, I32] -> [I32]
"wasi_snapshot_preview1"."environ_get": [I32, I32] -> [I32]
"wasi_snapshot_preview1"."environ_sizes_get": [I32, I32] -> [I32]
"wasi_snapshot_preview1"."fd_close": [I32] -> [I32]
"wasi_snapshot_preview1"."fd_fdstat_get": [I32, I32] -> [I32]
"wasi_snapshot_preview1"."fd_prestat_get": [I32, I32] -> [I32]
"wasi_snapshot_preview1"."fd_prestat_dir_name": [I32, I32, I32] -> [I32]
"wasi_snapshot_preview1"."fd_read": [I32, I32, I32, I32] -> [I32]
"wasi_snapshot_preview1"."fd_seek": [I32, I64, I32, I32] -> [I32]
"wasi_snapshot_preview1"."path_open": [I32, I32, I32, I32, I32, I64, I64, I32, I32] -> [I32]
"wasi_snapshot_preview1"."proc_exit": [I32] -> []
Memories:
Tables:
Globals:
Exports:
Functions:
"malloc": [I32] -> [I32]
"free": [I32] -> []
"calloc": [I32, I32] -> [I32]
"realloc": [I32, I32] -> [I32]
"_start": [] -> []
"getDocument": [I32, I32, I32] -> []
"asyncify_start_unwind": [I32] -> []
"asyncify_stop_unwind": [] -> []
"asyncify_start_rewind": [I32] -> []
"asyncify_stop_rewind": [] -> []
"asyncify_get_state": [] -> [I32]
Memories:
"memory": not shared (2 pages..)
Tables:
Globals: