-
Notifications
You must be signed in to change notification settings - Fork 799
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
Passing i64 around always fails with the js feature #3773
Comments
Can you try again with current master, mainy things have changed on the Js part so it might just work now. |
Ok, I have tried just that, and it is giving me a different error. This time, calling the You can clone this repo again, this time at the This is the new error:
This is the line that throws the error: #[inline]
pub fn param_from_js(ty: &Type, js_val: &JsValue) -> Value {
match ty {
Type::I32 => Value::I32(js_val.as_f64().unwrap() as _),
Type::I64 => {
let number = js_val.as_f64().map(|f| f as i64).unwrap_or_else(|| {
if js_val.is_bigint() {
// To support BigInt
let big_num: u128 = js_sys::BigInt::from(js_val.clone()).try_into().unwrap(); // <-- HERE
big_num as i64
} else {
(js_sys::Number::from(js_val.clone()).as_f64().unwrap()) as i64
}
});
Value::I64(number)
}
Type::F32 => Value::F32(js_val.as_f64().unwrap() as _),
Type::F64 => Value::F64(js_val.as_f64().unwrap()),
Type::V128 => {
let big_num: u128 = js_sys::BigInt::from(js_val.clone()).try_into().unwrap();
Value::V128(big_num)
}
Type::ExternRef | Type::FuncRef => unimplemented!(
"The type `{:?}` is not yet supported in the JS Function API",
ty
),
}
} Clearly, something is wrong with the |
Ok, passing any You can check out this repo again at the |
Passing
i64
to and from a module on the web always fails with thejs
featureWhen compiling wasmer itself to WASM using the
js
feature so that it can run in the browser, there is an error when you then load another plugin from wasmer and try to passi64
values around.Steps to reproduce
add-i64-result-error
tag.build.sh
script (after reading the entire source code, of course).Expected behavior
i64
values should be added correctly inside the plugin and the values should be passed between the plugin and wasmer without a problem.Actual behavior
Calling the
add_i64
exported function always returns a runtime error, example:Additional context
This was discovered when I was doing testing for #3763. Although this is a different error than I was experiencing there. That might be because I was using wasmer from source in that PR, whereas here I am using the currently released version
3.1.1
.Also, I followed this example by Mozilla on how to run Rust on the browser using
wasm-pack
, if that's relevant.The text was updated successfully, but these errors were encountered: