-
Notifications
You must be signed in to change notification settings - Fork 426
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lang] Improve invalid selector error (#561)
* [lang] Improve invalid selector message * [lang] Improve span * [lang] Return syn::Error instead of panicking * Make clippy happy * [lang] Reduce code dup with non_hex_err * [lang] Rename fn * [lang] Fix err functions * [lang] Add comments * [lang] Remove unnecessary lifetime
- Loading branch information
Showing
4 changed files
with
50 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
crates/lang/macro/tests/ui/fail/M-05-message-invalid-selector.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use ink_lang as ink; | ||
|
||
#[ink::contract] | ||
mod message_invalid_selector { | ||
#[ink(storage)] | ||
pub struct MessageInvalidSelector {} | ||
|
||
impl MessageInvalidSelector { | ||
#[ink(constructor)] | ||
pub fn constructor() -> Self { | ||
Self {} | ||
} | ||
|
||
#[ink(message, selector = "0x00")] | ||
pub fn invalid_selector(&self) { } | ||
} | ||
} | ||
|
||
fn main() {} |
5 changes: 5 additions & 0 deletions
5
crates/lang/macro/tests/ui/fail/M-05-message-invalid-selector.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
error: invalid selector - a selector must consist of four bytes in hex (e.g. `selector = "0xCAFEBABE"`) | ||
--> $DIR/M-05-message-invalid-selector.rs:14:24 | ||
| | ||
14 | #[ink(message, selector = "0x00")] | ||
| ^^^^^^^^^^^^^^^^^ |