Skip to content
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

Error compiling to wasm index out of bounds when implementing IntoWasmAbi #3574

Closed
dgkf opened this issue Aug 28, 2023 · 2 comments
Closed
Labels

Comments

@dgkf
Copy link

dgkf commented Aug 28, 2023

Describe the Bug

Introducing implementations of WasmDescribe, IntoWasmAbi and FromWasmAbi cause builds to fail with error:

[INFO]: 🎯  Checking for the Wasm target...
[INFO]: 🌀  Compiling to Wasm...
   Compiling test-wasm-bindgen v0.1.0 (~/Projects/Programming/test-wasm-binding)
    Finished release [optimized] target(s) in 0.10s
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasm-bindgen-cli-support-0.2.87/src/descriptor.rs:218:15

Steps to Reproduce

  1. Create a simple rust lib crate (I used the hello-world example as a basis)
  2. Introduce a return type that requires an implementation of IntoWasmAbi/FromWasmAbi
  3. Attempt to build
  4. Observe error

see this repo with the code used to minimally produce the bug

Expected Behavior

The build succeeds

Actual Behavior

The build fails with an index out of bounds error

Additional Context

This seems to have popped up from time to time in wasm-bindgen's history with,
seemingly resolved by matching dependency versions (#3441, #2776, among others).

Troubleshooting

  • Build error only arises when IntoWasmAbi/FromWasmAbi are implemented for a new type.
  • As far as I can tell, dependency versions are all the same. I've tried many
    of the older versions that resolved previous issues to no avail (0.2.78, 0.2.79, 0.2.84).
  • Attempted reinstalling wasm-pack with wasm-pack --locked to no avail
@dgkf dgkf added the bug label Aug 28, 2023
@dgkf
Copy link
Author

dgkf commented Aug 28, 2023

I'm realizing that perhaps the intention is not to be able to define arbitrary types, but to coerce a type into one of the already provided WasmAbi options. I had sort of hoped that wasm-bindgen would do some magic for simple structs, but I'm not seeing evidence of it in the docs.

I was loosely trying to follow this example, and I'm not sure if I misunderstood the struct here to be an example when instead it is just meant to show a special case. If the latter, feel free to close as user error.

@daxpedda
Copy link
Collaborator

I'm realizing that perhaps the intention is not to be able to define arbitrary types, but to coerce a type into one of the already provided WasmAbi options.

Pretty much, in your minimal example you didn't add a description to WasmDescribe, so this can't really work. But all of this is subject to the ABI implemented by wasm-bindgen which you can't really expand.

@daxpedda daxpedda closed this as not planned Won't fix, can't repro, duplicate, stale Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants