-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[bug fix][move] Removed compiler unwrap (#17484)
## Description - Fixes #17426 - The id-leak assumed pack visibility was a blocking error ## Test plan - Added a test --- ## 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: - [X] CLI: Fixed a bug where the Move compiler could panic when instantiating an object outside of its defining module. - [ ] Rust SDK:
- Loading branch information
Showing
3 changed files
with
35 additions
and
1 deletion.
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
7 changes: 7 additions & 0 deletions
7
external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/private_pack.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,7 @@ | ||
error[E04001]: restricted visibility | ||
┌─ tests/sui_mode/id_leak/private_pack.move:19:9 | ||
│ | ||
19 │ A { id } | ||
│ ^^^^^^^^ Invalid instantiation of 'a::a::A'. | ||
All structs can only be constructed in the module in which they are declared | ||
|
27 changes: 27 additions & 0 deletions
27
external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/private_pack.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,27 @@ | ||
// not allowed since C is not packed with a fresh UID | ||
module a::a { | ||
use sui::object::UID; | ||
|
||
struct A has key { | ||
id: UID | ||
} | ||
} | ||
|
||
module b::b { | ||
use sui::object::UID; | ||
use a::a::A; | ||
|
||
struct B has key { | ||
id: UID | ||
} | ||
public fun no(b: B): A { | ||
let B { id } = b; | ||
A { id } | ||
} | ||
} | ||
|
||
module sui::object { | ||
struct UID has store { | ||
id: address, | ||
} | ||
} |