File tree Expand file tree Collapse file tree 3 files changed +22
-4
lines changed
sway-core/src/abi_generation
test/src/e2e_vm_tests/test_programs/should_fail/attributes_invalid_abi_names Expand file tree Collapse file tree 3 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -182,7 +182,10 @@ impl TypeId {
182
182
} ;
183
183
184
184
if has_abi_name_attribute {
185
- if name. is_empty ( ) || !is_valid_identifier_or_path ( name. as_str ( ) ) {
185
+ if name. is_empty ( )
186
+ || !is_valid_identifier_or_path ( name. as_str ( ) )
187
+ || name. starts_with ( "::" )
188
+ {
186
189
err = Some ( handler. emit_err ( CompileError :: ABIInvalidName {
187
190
span : attribute_name_span. clone ( ) ,
188
191
name,
Original file line number Diff line number Diff line change @@ -28,6 +28,9 @@ struct MyStruct5 {}
28
28
#[abi_name(name = " OtherStruct" )]
29
29
struct MyStruct6 {}
30
30
31
+ #[abi_name(name = " ::some_module::in_the_same::package" )]
32
+ struct MyStruct7 {}
33
+
31
34
// OK because enums are on a different namespace
32
35
#[abi_name(name = " SameName" )]
33
36
enum MyEnum {
@@ -49,6 +52,7 @@ abi MyAbi {
49
52
fn my_struct4 () -> MyStruct4 ;
50
53
fn my_struct5 () -> MyStruct5 ;
51
54
fn my_struct6 () -> MyStruct6 ;
55
+ fn my_struct7 () -> MyStruct7 ;
52
56
fn other_enum () -> OtherEnum ;
53
57
fn my_enum () -> MyEnum ;
54
58
fn my_enum1 () -> MyEnum1 ;
@@ -64,6 +68,7 @@ impl MyAbi for Contract {
64
68
fn my_struct4 () -> MyStruct4 { MyStruct4 {} }
65
69
fn my_struct5 () -> MyStruct5 { MyStruct5 {} }
66
70
fn my_struct6 () -> MyStruct6 { MyStruct6 {} }
71
+ fn my_struct7 () -> MyStruct7 { MyStruct7 {} }
67
72
fn other_enum () -> OtherEnum { OtherEnum :: A }
68
73
fn my_enum () -> MyEnum { MyEnum :: A }
69
74
fn my_enum1 () -> MyEnum1 { MyEnum1 :: A }
Original file line number Diff line number Diff line change @@ -8,10 +8,10 @@ output:
8
8
Compiling library std (sway - lib - std )
9
9
Compiling contract attributes_invalid_abi_names (test / src / e2e_vm_tests / test_programs / should_fail / attributes_invalid_abi_names )
10
10
error : Duplicated name found for renamed ABI type
11
- -- > test / src / e2e_vm_tests / test_programs / should_fail / attributes_invalid_abi_names / src / main .sw :37 :19
11
+ -- > test / src / e2e_vm_tests / test_programs / should_fail / attributes_invalid_abi_names / src / main .sw :40 :19
12
12
|
13
13
...
14
- 37 | #[abi_name (name = " OtherEnum" )]
14
+ 40 | #[abi_name (name = " OtherEnum" )]
15
15
| ^^^^^^^^^^^
16
16
|
17
17
::: test / src / e2e_vm_tests / test_programs / should_fail / attributes_invalid_abi_names / src / other .sw :7 :10
@@ -98,5 +98,15 @@ error: Duplicated name found for renamed ABI type
98
98
|
99
99
____
100
100
101
- Aborting due to 7 errors .
101
+ error : Invalid name found for renamed ABI type .
102
+ -- > test / src / e2e_vm_tests / test_programs / should_fail / attributes_invalid_abi_names / src / main .sw :31 :19
103
+ |
104
+ ...
105
+ 31 | #[abi_name (name = " ::some_module::in_the_same::package" )]
106
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
107
+ |
108
+ = help : The name must be a valid Sway identifier .
109
+ ____
110
+
111
+ Aborting due to 8 errors .
102
112
error : Failed to compile attributes_invalid_abi_names
You can’t perform that action at this time.
0 commit comments