-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Implement FromWasmAbi for Result<i32|u32, JsValue> #1528
Comments
It's intended that |
Here is an example pub mod Atomics {
use super::*;
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(js_namespace = Atomics, catch)]
pub fn add(typed_array: &JsValue, index: u32, value: i32) -> Result<JsValue, JsValue>; When I run
The error points here https://github.com/rustwasm/wasm-bindgen/blob/master/crates/js-sys/src/lib.rs#L519 |
Sorry I think I still may not be quite following, could you perhaps gist a standalone example that exhibits the error? |
Found it! I was confused by error message. use wasm_bindgen::prelude::*;
pub mod Namespace {
use super::*;
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(js_namespace = Namespace)]
pub fn example() -> Result<JsValue, JsValue>;
}
} If we try to run
The mistake in code is missing #[wasm_bindgen(js_namespace = Namespace)]
pub fn example() -> Result<JsValue, JsValue>; and the following code compiles: #[wasm_bindgen(js_namespace = Namespace, catch)]
pub fn example() -> Result<JsValue, JsValue>; |
Hm I'm unfortunately still having difficulty reproducing this and I don't know why, @ibaryshnikov can you perhaps send a PR adding a test to |
@alexcrichton I tried to add the code to |
This commit tweaks the codegen for imported functions and such (anything that relies on some imported intrinsic or function filled in by the CLI) to share as much code as possible on non-wasm32 platforms. This should help us catch more errors before compiling to wasm and also just make it easier to write UI tests! For example a UI test previously couldn't be written for rustwasm#1528 but now it can be, and one is include (although the error message is quite bad).
Rejigger a few spans, work around an odd rustc issue, and hopefully produce higher quality error messages! Closes rustwasm#1528
It looks like there's no
FromWasmAbi
implementation forResult<u32, JsValue>
andResult<i32, JsValue>
The feature is required by #1379, since there are return types like
Result<i32, JsValue>
inAtomics
https://github.com/rustwasm/wasm-bindgen/blob/master/crates/js-sys/src/lib.rs#L528
The text was updated successfully, but these errors were encountered: