wasm-bindgen icon indicating copy to clipboard operation
wasm-bindgen copied to clipboard

Long typescript_type leads to compile error in debug mode

Open anlumo opened this issue 3 years ago • 0 comments

Describe the Bug

When compiling in debug mode, having a long typescript_type annotation for a custom type leads to a compiler error. Release mode works fine.

Steps to Reproduce

Example code:

use wasm_bindgen::{prelude::*, JsCast};

#[wasm_bindgen]
extern "C" {
    #[wasm_bindgen(typescript_type = "{                                                         }")]
    pub type Foo;
}

#[wasm_bindgen]
pub fn foo() -> Foo {
    JsValue::from_f64(0.0).unchecked_into()
}

Build with:

wasm-pack build --debug --target web

Expected Behavior

Finished dev [unoptimized + debuginfo] target(s) in 0.34s
...
[INFO]: :-) Your wasm pkg is ready to publish at ...

Actual Behavior

    Finished dev [unoptimized + debuginfo] target(s) in 0.38s
[WARN]: :-) origin crate has no README
thread 'main' panicked at 'index out of bounds: the len is 256 but the index is 1073741823', [...]/wasm-bindgen-wasm-interpreter-0.2.79/src/lib.rs:307:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: Running the wasm-bindgen CLI

Additional Context

If you remove a single space from the typescript type definition, it works. There seems to be a maximum length allowed there, which seems to be around 58 characters (in my own project, the limit seems to be 54 characters for some reason). The content doesn't appear to matter.

Release builds work fine, this only fails in debug builds.

anlumo avatar Apr 01 '22 18:04 anlumo