Marking a mutating function on a structure @JS results in a compilation failure in the generated code.
For example, this struct generates code which fails to compile.
@JS struct Counter {
var number: Int
@JS public mutating func increment() {
number += 1
}
}
@_expose(wasm, "bjs_Counter_increment")
@_cdecl("bjs_Counter_increment")
public func _bjs_Counter_increment() -> Void {
#if arch(wasm32)
Counter.bridgeJSLiftParameter().increment() // error: cannot use mutating member on immutable value: function call returns immutable value
#else
fatalError("Only available on WebAssembly")
#endif
}
Marking a mutating function on a structure
@JSresults in a compilation failure in the generated code.For example, this struct generates code which fails to compile.