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

Fix handling of u32 between Rust and JS #1401

Merged
merged 1 commit into from
Mar 27, 2019

Conversation

alexcrichton
Copy link
Contributor

All numbers in WebAssembly are signed and then each operation on them
may optionally have an unsigned version. This means that when we pass
large signed numbers to JS they actually show up as large negative
numbers even though JS numbers can faithfully represent the type.

This is fixed by adding >>>0 in a few locations in the generated
bindings to coerce the JS value into an unsigned value.

Closes #1388

Copy link
Contributor

@Pauan Pauan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nits, but nothing blocking. Looks good to me!

crates/cli-support/src/descriptor.rs Outdated Show resolved Hide resolved
crates/cli-support/src/descriptor.rs Outdated Show resolved Hide resolved
tests/wasm/math.rs Show resolved Hide resolved
All numbers in WebAssembly are signed and then each operation on them
may optionally have an unsigned version. This means that when we pass
large signed numbers to JS they actually show up as large negative
numbers even though JS numbers can faithfully represent the type.

This is fixed by adding `>>>0` in a few locations in the generated
bindings to coerce the JS value into an unsigned value.

Closes rustwasm#1388
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

u32 interpreted as i32 when passed to JS
2 participants