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

expression has type externref but expected i32 #2446

Closed
domoritz opened this issue Feb 4, 2021 · 6 comments · Fixed by #2450
Closed

expression has type externref but expected i32 #2446

domoritz opened this issue Feb 4, 2021 · 6 comments · Fixed by #2450
Labels

Comments

@domoritz
Copy link
Contributor

domoritz commented Feb 4, 2021

Describe the Bug

When I compile my project with --reference-types, I get expression has type externref but expected i32 in Firefox (nightly 87.0a1 (2021-02-04) as well as beta) and Chrome (with flags to enable reference types).

Steps to Reproduce

  1. Clone https://github.com/domoritz/arrow-wasm/tree/bc8cc58b0cdedf4754a190de62b6d5a088ac40b5
  2. Install wasm bindgen cli
  3. Run yarn build
  4. Start python web server
  5. Go to http://localhost:8000/examples/index_web.html (ideally in FF so you don't need extra flags to enable reference types)
  6. See error

Expected Behavior

Without --reference-types the library works so I would expect it to work with the flag as well.

Actual Behavior

Error expression has type externref but expected i32.

Screen Shot 2021-02-04 at 21 44 52

@domoritz domoritz added the bug label Feb 4, 2021
@alexcrichton
Copy link
Contributor

Would you be able to upload the wasm file? Additionally could you clarify which wasm-bindgen-cli version you're using?

@domoritz
Copy link
Contributor Author

domoritz commented Feb 8, 2021

Thanks for looking into my issue. wasm-bindgen v0.2.70 (via wasm-bindgen --version). I uploaded the lockfile and wasm files to https://github.com/domoritz/arrow-wasm/tree/dom/reference-types (wasm file is at https://github.com/domoritz/arrow-wasm/blob/dom/reference-types/pkg/arrow_wasm_bg.wasm).

@alexcrichton
Copy link
Contributor

Was this file perhaps run through wasm-opt? If you disable that does it work for you?

@domoritz
Copy link
Contributor Author

domoritz commented Feb 8, 2021

I don't think so. This is my build script.

Screen Shot 2021-02-08 at 18 04 16

alexcrichton added a commit to alexcrichton/wasm-bindgen that referenced this issue Feb 9, 2021
It's not safe for us to arbitrarily modify the instruction stream since
wasm isn't guaranteed to be an AST! Instead we resort to a few extra
instructions with locals to achieve what we want here.

Closes rustwasm#2446
@alexcrichton
Copy link
Contributor

Ok thanks for clarifying! I dug in a bit and this should be fixed in #2450. Thanks again for the report!

@domoritz
Copy link
Contributor Author

domoritz commented Feb 9, 2021

Awesome. I'm glad I could help. Thank you for the fix (and all your work on the Rust wasm ecosystem)!

alexcrichton added a commit that referenced this issue Feb 9, 2021
It's not safe for us to arbitrarily modify the instruction stream since
wasm isn't guaranteed to be an AST! Instead we resort to a few extra
instructions with locals to achieve what we want here.

Closes #2446
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