-
Notifications
You must be signed in to change notification settings - Fork 449
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check namespace argument is identifier (#931)
* check that argument in #[ink(namespace = "argument")] is a Rust identifier * add UI tests for #[ink(namespace = "..")] ink! property # Conflicts: # crates/lang/macro/tests/compile_tests.rs # crates/lang/macro/tests/ui/fail/N-01-namespace-invalid-identifier.rs # crates/lang/macro/tests/ui/fail/N-01-namespace-invalid-identifier.stderr # crates/lang/macro/tests/ui/fail/N-02-namespace-invalid-type.rs # crates/lang/macro/tests/ui/fail/N-02-namespace-invalid-type.stderr # crates/lang/macro/tests/ui/fail/N-03-namespace-missing-argument.rs # crates/lang/macro/tests/ui/fail/N-03-namespace-missing-argument.stderr * fix error message for non-identifier namespace argument
- Loading branch information
Showing
8 changed files
with
96 additions
and
2 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
20 changes: 20 additions & 0 deletions
20
crates/lang/macro/tests/ui/fail/N-01-namespace-invalid-identifier.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,20 @@ | ||
use ink_lang as ink; | ||
|
||
#[ink::contract] | ||
mod invalid_namespace_identifier { | ||
#[ink(storage)] | ||
pub struct MyStorage {} | ||
|
||
#[ink(namespace = "::invalid_identifier")] | ||
impl MyStorage { | ||
#[ink(constructor)] | ||
pub fn constructor() -> Self { | ||
Self {} | ||
} | ||
|
||
#[ink(message)] | ||
pub fn message(&self) {} | ||
} | ||
} | ||
|
||
fn main() {} |
5 changes: 5 additions & 0 deletions
5
crates/lang/macro/tests/ui/fail/N-01-namespace-invalid-identifier.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: encountered invalid Rust identifier for namespace argument | ||
--> $DIR/N-01-namespace-invalid-identifier.rs:8:23 | ||
| | ||
8 | #[ink(namespace = "::invalid_identifier")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^ |
20 changes: 20 additions & 0 deletions
20
crates/lang/macro/tests/ui/fail/N-02-namespace-invalid-type.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,20 @@ | ||
use ink_lang as ink; | ||
|
||
#[ink::contract] | ||
mod invalid_namespace_identifier { | ||
#[ink(storage)] | ||
pub struct MyStorage {} | ||
|
||
#[ink(namespace = true)] | ||
impl MyStorage { | ||
#[ink(constructor)] | ||
pub fn constructor() -> Self { | ||
Self {} | ||
} | ||
|
||
#[ink(message)] | ||
pub fn message(&self) {} | ||
} | ||
} | ||
|
||
fn main() {} |
5 changes: 5 additions & 0 deletions
5
crates/lang/macro/tests/ui/fail/N-02-namespace-invalid-type.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: expecteded string type for `namespace` argument, e.g. #[ink(namespace = "hello")] | ||
--> $DIR/N-02-namespace-invalid-type.rs:8:11 | ||
| | ||
8 | #[ink(namespace = true)] | ||
| ^^^^^^^^^^^^^^^^ |
20 changes: 20 additions & 0 deletions
20
crates/lang/macro/tests/ui/fail/N-03-namespace-missing-argument.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,20 @@ | ||
use ink_lang as ink; | ||
|
||
#[ink::contract] | ||
mod invalid_namespace_identifier { | ||
#[ink(storage)] | ||
pub struct MyStorage {} | ||
|
||
#[ink(namespace)] | ||
impl MyStorage { | ||
#[ink(constructor)] | ||
pub fn constructor() -> Self { | ||
Self {} | ||
} | ||
|
||
#[ink(message)] | ||
pub fn message(&self) {} | ||
} | ||
} | ||
|
||
fn main() {} |
5 changes: 5 additions & 0 deletions
5
crates/lang/macro/tests/ui/fail/N-03-namespace-missing-argument.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: encountered #[ink(namespace)] that is missing its string parameter. Did you mean #[ink(namespace = name: str)] ? | ||
--> $DIR/N-03-namespace-missing-argument.rs:8:11 | ||
| | ||
8 | #[ink(namespace)] | ||
| ^^^^^^^^^ |