You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I use #[wasm_bindgen(js_name = parseFloat)] to import the same js function in two modules, with the same rust fn name, but with different signatures, things don't work well.
use wasm_bindgen::JsValue;use wasm_bindgen_test::*;mod a {use wasm_bindgen::prelude::*;#[wasm_bindgen]extern"C"{#[wasm_bindgen(js_name = parseFloat)]pubfnparse_float(text:&JsValue) -> f64;}}mod b {use wasm_bindgen::prelude::*;#[wasm_bindgen]extern"C"{#[wasm_bindgen(js_name = parseFloat)]pubfnparse_float(text:&str) -> f64;}}#[wasm_bindgen_test]pubfnpass_a(){let v = JsValue::from_str("1");assert_eq!(a::parse_float(&v),1.);}#[wasm_bindgen_test]pubfnpass_b(){assert_eq!(b::parse_float("2"),2.);}
The above test failed.
const wasmModule = new WebAssembly.Module(bytes);
^
CompileError: WebAssembly.Module(): Compiling function #838:"f64::a::parse_float::hfd12f3d441bd8268" failed: not enough arguments on the stack for call (need 2, got 1) @+435657
Imports with the same js name and rust name should all work.
Actual Behavior
If the imports have the same js name and rust name, it seems that they all link to the same bindgen js function. So if they have different signatures, calling one of them failed at runtime.
The text was updated successfully, but these errors were encountered:
Describe the Bug
If I use
#[wasm_bindgen(js_name = parseFloat)]
to import the same js function in two modules, with the same rust fn name, but with different signatures, things don't work well.The above test failed.
Steps to Reproduce
wasm-pack test --node
Expected Behavior
Imports with the same js name and rust name should all work.
Actual Behavior
If the imports have the same js name and rust name, it seems that they all link to the same bindgen js function. So if they have different signatures, calling one of them failed at runtime.
The text was updated successfully, but these errors were encountered: