mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-12 12:31:22 +00:00
Improve error message for infer_setter_property
If the setter doesn't start with `set_*` then we currently panic, but panicking is bad! Instead let's thread through structured errors to make sure they make their way to the top
This commit is contained in:
19
crates/macro/ui-tests/invalid-setter.rs
Normal file
19
crates/macro/ui-tests/invalid-setter.rs
Normal file
@ -0,0 +1,19 @@
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen]
|
||||
extern "C" {
|
||||
type A;
|
||||
|
||||
#[wasm_bindgen(setter, method)]
|
||||
fn a(this: &A, b: i32);
|
||||
|
||||
#[wasm_bindgen(setter = x, method)]
|
||||
fn b(this: &A, b: i32);
|
||||
|
||||
#[wasm_bindgen(setter, method, js_name = x)]
|
||||
fn c(this: &A, b: i32);
|
||||
}
|
||||
|
||||
fn main() {}
|
14
crates/macro/ui-tests/invalid-setter.stderr
Normal file
14
crates/macro/ui-tests/invalid-setter.stderr
Normal file
@ -0,0 +1,14 @@
|
||||
error: setters must start with `set_`, found: a
|
||||
--> $DIR/invalid-setter.rs:10:8
|
||||
|
|
||||
10 | fn a(this: &A, b: i32);
|
||||
| ^
|
||||
|
||||
error: setters must start with `set_`, found: x
|
||||
--> $DIR/invalid-setter.rs:15:46
|
||||
|
|
||||
15 | #[wasm_bindgen(setter, method, js_name = x)]
|
||||
| ^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
Reference in New Issue
Block a user