Skip to content

Async function returning unit triggers assert_signature_match assertion failure #1781

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
NathanFlurry opened this issue Sep 20, 2019 · 1 comment · Fixed by #1782
Closed
Labels

Comments

@NathanFlurry
Copy link

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

  1. Create lib.rs containing this code:
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub async fn run() {
    println!("Hello, world!");

    ()
}
  1. 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)

alexcrichton added a commit to alexcrichton/wasm-bindgen that referenced this issue Sep 20, 2019
They erroneously reported returning the original return type, not the
promise! Let's also add a bunch of positive tests while we're at it.

Closes rustwasm#1781
@alexcrichton
Copy link
Contributor

Oh dear, sorry for the runaround on the bug here! Should be fixed in #1782

alexcrichton added a commit that referenced this issue Sep 20, 2019
They erroneously reported returning the original return type, not the
promise! Let's also add a bunch of positive tests while we're at it.

Closes #1781
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants