forked from MystenLabs/sui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[move][move-2024] Add raw address support for patterns (MystenLabs#18482
) ## Description This allows raw addresses to be used as pattern prefixes ## Test plan New tests --- ## Release notes Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required. For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates. - [ ] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] Indexer: - [ ] JSON-RPC: - [ ] GraphQL: - [ ] CLI: - [ ] Rust SDK:
- Loading branch information
Showing
4 changed files
with
102 additions
and
55 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
11 changes: 11 additions & 0 deletions
11
external-crates/move/crates/move-compiler/tests/move_2024/matching/raw_address.move
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,11 @@ | ||
module 0x42::m; | ||
|
||
public enum E { | ||
V0(u64, u64) | ||
} | ||
|
||
public fun match_e(e: &E): (&u64, &u64) { | ||
match (e) { | ||
0x42::m::E::V0(x, y) => (x, y), | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
external-crates/move/crates/move-compiler/tests/move_2024/matching/raw_address_invalid.exp
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,18 @@ | ||
error[E04007]: incompatible types | ||
┌─ tests/move_2024/matching/raw_address_invalid.move:10:9 | ||
│ | ||
7 │ public fun match_e(e: &E, rx: &u64, ry: &u64): (&u64, &u64) { | ||
│ - Expected: '0x42::m::E' | ||
· | ||
10 │ 0x42 => (rx, ry), | ||
│ ^^^^ | ||
│ │ | ||
│ Invalid pattern | ||
│ Given: integer | ||
|
||
error[E03006]: unexpected name in this position | ||
┌─ tests/move_2024/matching/raw_address_invalid.move:11:9 | ||
│ | ||
11 │ 0x42::m => (rx, ry), | ||
│ ^^^^^^^ Unexpected module identifier. A module identifier is not a valid pattern constructor | ||
|
13 changes: 13 additions & 0 deletions
13
external-crates/move/crates/move-compiler/tests/move_2024/matching/raw_address_invalid.move
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,13 @@ | ||
module 0x42::m; | ||
|
||
public enum E { | ||
V0(u64, u64) | ||
} | ||
|
||
public fun match_e(e: &E, rx: &u64, ry: &u64): (&u64, &u64) { | ||
match (e) { | ||
0x42::m::E::V0(x, y) => (x, y), | ||
0x42 => (rx, ry), | ||
0x42::m => (rx, ry), | ||
} | ||
} |