E4219#
Compiler diagnostic name: invalid_export_name.
The #export_name attribute is invalid. MoonBit currently requires exported
names to be unique valid C symbol identifiers for every backend. The attribute
may be used only on public, non-generic function definitions without optional
arguments in a foreign-library package.
Warning
Known compiler issue: #export_name currently applies its C-symbol-identifier
restriction to every backend. WebAssembly export names are UTF-8 strings and
are not limited to C identifiers.
Erroneous example#
///|
#export_name("bad-name")
pub fn add_one(value : Int) -> Int {
value + 1
}
Suggestion#
Use a valid symbol name and declare the package as a foreign library with
pkgtype(kind: "foreign_library").
///|
#export_name("add_one")
pub fn add_one(value : Int) -> Int {
value + 1
}