Closed
Description
Describe the Bug
When returning a unit or a value such as a Result<(), JsValue>
which contains a unit from an async function, this assertion fails.
Steps to Reproduce
- Create
lib.rs
containing this code:
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub async fn run() {
println!("Hello, world!");
()
}
- Run
rustup run nightly wasm-pack build --target web
Expected Behavior
wasm-bindgen
will either convert the unit as a corresponding JsValue
(likely null
or undefined
) or log an error at compile time.
Actual Behavior
The compilation will succeed, but wasm-bindgen
will panic when the assertion fails.
Example output:
[INFO]: 🎯 Checking for the Wasm target...
[INFO]: 🌀 Compiling to Wasm...
Finished release [optimized] target(s) in 0.08s
⚠️ [WARN]: origin crate has no README
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `1`,
right: `0`', crates/cli-support/src/webidl/bindings.rs:208:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
Error: Running the wasm-bindgen CLI
Caused by: failed to execute `wasm-bindgen`: exited with exit code: 101
Additional Context
wasm-bindgen
, wasm-bindgen-futures
, js-sys
, web-sys
, and CLI version: master branch (93f5bba at the time of writing); also tested on 8861811 to validate this is not a regression
wasm-pack
version: Both 0.9.0 or 0.8.1 do not work
Rust version: rustc 1.39.0-nightly (9b9d2aff8 2019-09-19)