Skip to content

Commit

Permalink
[bug fix][move] Removed compiler unwrap (#17484)
Browse files Browse the repository at this point in the history
## 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
tnowacki authored May 3, 2024
1 parent 228d754 commit 4fd8fea
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl<'a> SimpleAbsInt for IDLeakVerifierAI<'a> {
let E::Pack(s, _tys, fields) = e__ else {
return None;
};
let abilities = self.declared_abilities.get(s).unwrap();
let abilities = self.declared_abilities.get(s)?;
if !abilities.has_ability_(Ability_::Key) {
return None;
}
Expand Down
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

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,
}
}

0 comments on commit 4fd8fea

Please sign in to comment.