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
Declaring and using a static with a type that is e.g. String or Option<_> compiles, but causes an index out of bounds error when running the wasm-bindgen CLI step in wasm-pack. Types that are handles to JavaScript values(JsValue, js_sys::Array, wasm-bindgen types generated from type declarations in extern "C" blocks) work fine.
Steps to Reproduce
Set up the following project, and run wasm-pack build.
use wasm_bindgen::prelude::*;#[wasm_bindgen]extern"C"{staticEXTENSION_ROOT:String;}#[wasm_bindgen]pubfnhello() -> String{EXTENSION_ROOT.clone()}
This should either create a static correctly and use *WasmAbi implicit conversions, or result in a non-panic error at some stage of compilation.
Actual Behavior
A panic in the build process occurs:
[INFO]: Checking for the Wasm target...
[INFO]: Compiling to Wasm...
Finished release [optimized] target(s) in 0.01s
:-) [WARN]: origin crate has no README
[INFO]: Installing wasm-bindgen...
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', crates/cli-support/src/webidl/bindings.rs:209:36
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: rust_begin_unwind
5: core::panicking::panic_fmt
6: core::panicking::panic_bounds_check
7: wasm_bindgen_cli_support::webidl::bindings::assert_signature_match
8: wasm_bindgen_cli_support::webidl::bindings::register_import
9: wasm_bindgen_cli_support::webidl::Context::program
10: wasm_bindgen_cli_support::webidl::process
11: wasm_bindgen_cli_support::Bindgen::generate_output
12: wasm_bindgen_cli_support::Bindgen::generate
13: wasm_bindgen::main
14: std::rt::lang_start::{{closure}}
15: std::panicking::try::do_call
16: __rust_maybe_catch_panic
17: std::rt::lang_start_internal
18: main
Error: Running the wasm-bindgen CLI
Caused by: failed to execute `wasm-bindgen`: exited with exit code: 101
The text was updated successfully, but these errors were encountered:
This hasn't ever actually worked in `wasm-bindgen` but there's been
enough refactorings since the initial implementation that it's actually
quite trivial to implement now!
Closesrustwasm#1777
Thanks for the report! Funnily enough this hasn't actually ever worked, but we just forgot to get around to fixing it! Nowadays though I think the fix should be pretty easy -- #1784
This hasn't ever actually worked in `wasm-bindgen` but there's been
enough refactorings since the initial implementation that it's actually
quite trivial to implement now!
Closes#1777
Describe the Bug
Declaring and using a static with a type that is e.g.
String
orOption<_>
compiles, but causes an index out of bounds error when running the wasm-bindgen CLI step in wasm-pack. Types that are handles to JavaScript values(JsValue
,js_sys::Array
, wasm-bindgen types generated fromtype
declarations inextern "C"
blocks) work fine.Steps to Reproduce
Set up the following project, and run
wasm-pack build
.Expected Behavior
This should either create a static correctly and use *WasmAbi implicit conversions, or result in a non-panic error at some stage of compilation.
Actual Behavior
A panic in the build process occurs:
The text was updated successfully, but these errors were encountered: