rustwasm / wasm-bindgen

Facilitating high-level interactions between Wasm modules and JavaScript
https://rustwasm.github.io/docs/wasm-bindgen/
Apache License 2.0
7.43k stars 1.02k forks source link

enum Error #1807

Open rbtcollins opened 4 years ago

rbtcollins commented 4 years ago

Describe the Bug

an Enum called Error casses an assertion in wasm-bindgen

Steps to Reproduce

I haven't done a minimal reproduction yet, but commenting out the following enum in my source fixed the assertion...

#[wasm_bindgen]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Error {
    BadRounds,
}

If applicable, add a link to a test case (as a zip file or link to a repository we can clone).

Expected Behavior

No assertion

Actual Behavior

    Finished release [optimized] target(s) in 0.68s
[INFO]: Installing wasm-bindgen...
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `"Error"`,
 right: `"Error2"`', crates/cli-support/src/js/mod.rs:156:21
stack backtrace:
   0: std::panicking::default_hook::{{closure}}
   1: std::panicking::default_hook
   2: std::panicking::rust_panic_with_hook
   3: std::panicking::continue_panic_fmt
   4: std::panicking::begin_panic_fmt
   5: wasm_bindgen_cli_support::js::Context::export
   6: wasm_bindgen_cli_support::js::Context::generate
   7: wasm_bindgen_cli_support::Bindgen::generate_output
   8: wasm_bindgen_cli_support::Bindgen::generate
   9: wasm_bindgen::main
  10: std::rt::lang_start::{{closure}}
  11: std::panicking::try::do_call
  12: __rust_maybe_catch_panic
  13: std::rt::lang_start_internal
  14: main
Error: Running the wasm-bindgen CLI
Caused by: failed to execute `wasm-bindgen`: exited with exit code: 101

Additional Context

Add any other context about the problem here.

alexcrichton commented 4 years ago

Thanks for the report, and sorry for the delay in getting to this!

I unfortunately won't have a chance to look at this in the near future, but I suspect that this isn't playing well with the js_sys::Error type. It's probably best to rename enum Error for now, but this probably isn't the hardest thing to handle after some investigation into the CLI!

sagudev commented 4 years ago

Got the same problem with enum named Element. Renaming it solved problem. Maybe if we put on line 161 check like on line 149, we could fix this problem.