
--allow-undefined can be a problem: it allows compiling code that will fail when loaded. This change makes sure that if some symbols are undefined, they are reported as an error by the linker. Previously, people could get away with importing a function that was not defined, like this: func add(int a, int b) int func test() { println(add(3, 5)) } This was always unintended but mostly worked. With this change, it isn't possible anymore. Now every function needs to be marked with //export explicitly: //export add func add(int a, int b) int func test() { println(add(3, 5)) } As before, functions will be placed in the `env` module with the name set from the `//export` tag. This can be overridden with `//go:import-module`: //go:import-module math //export add func add(int a, int b) int func test() { println(add(3, 5)) } For the syscall/js package, I needed to give a list of symbols that are undefined. This list is based on the JavaScript functions defined in targets/wasm_exec.js.
16 строки
375 Б
Text
16 строки
375 Б
Text
syscall/js.copyBytesToGo
|
|
syscall/js.copyBytesToJS
|
|
syscall/js.finalizeRef
|
|
syscall/js.stringVal
|
|
syscall/js.valueCall
|
|
syscall/js.valueDelete
|
|
syscall/js.valueGet
|
|
syscall/js.valueIndex
|
|
syscall/js.valueInstanceOf
|
|
syscall/js.valueInvoke
|
|
syscall/js.valueLength
|
|
syscall/js.valueLoadString
|
|
syscall/js.valueNew
|
|
syscall/js.valuePrepareString
|
|
syscall/js.valueSet
|
|
syscall/js.valueSetIndex
|