Skip to content

Commit

Permalink
add test for no fn attr on 'self' argument
Browse files Browse the repository at this point in the history
  • Loading branch information
rouzwelt committed Jan 9, 2025
1 parent 225acf5 commit 44f8a55
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
29 changes: 29 additions & 0 deletions crates/macro/ui-tests/invalid-self-fn-attrs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub struct A {
inner: u32
}

#[wasm_bindgen]
impl A {
#[wasm_bindgen]
pub fn method_with_self_attr1(
#[wasm_bindgen(unchecked_param_type = "number")]
&self,
arg: u32
) -> JsValue {
(self.inner + arg).into()
}

#[wasm_bindgen]
pub fn method_with_self_attr2(
#[wasm_bindgen(param_description = "some description")]
&self,
arg: u32
) -> JsValue {
(self.inner + arg).into()
}
}

fn main() {}
11 changes: 11 additions & 0 deletions crates/macro/ui-tests/invalid-self-fn-attrs.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error: expected non-macro attribute, found attribute macro `wasm_bindgen`
--> ui-tests/invalid-self-fn-attrs.rs:12:11
|
12 | #[wasm_bindgen(unchecked_param_type = "number")]
| ^^^^^^^^^^^^ not a non-macro attribute

error: expected non-macro attribute, found attribute macro `wasm_bindgen`
--> ui-tests/invalid-self-fn-attrs.rs:21:11
|
21 | #[wasm_bindgen(param_description = "some description")]
| ^^^^^^^^^^^^ not a non-macro attribute

0 comments on commit 44f8a55

Please sign in to comment.