-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix v1 test input /resources_invalid.move to match v2 test input,
and add 2 other variants of the test.
- Loading branch information
1 parent
a912dfe
commit b735a59
Showing
9 changed files
with
144 additions
and
7 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
third_party/move/move-compiler-v2/tests/checking/inlining/resources_valid.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,29 @@ | ||
// -- Model dump before bytecode pipeline | ||
module 0x42::objects { | ||
struct ReaderRef { | ||
addr: address, | ||
} | ||
public fun get_addr<T>(ref: &objects::ReaderRef<#0>): address { | ||
select objects::ReaderRef.addr<&objects::ReaderRef<T>>(ref) | ||
} | ||
public inline fun reader<T>(ref: &objects::ReaderRef<#0>): � { | ||
BorrowGlobal(Immutable)<T>(objects::get_addr<T>(ref)) | ||
} | ||
} // end 0x42::objects | ||
module 0x42::token { | ||
use 0x42::objects as obj; // resolved as: 0x42::objects | ||
struct Token { | ||
val: u64, | ||
} | ||
public fun get_value(ref: &objects::ReaderRef<token::Token>): u64 | ||
acquires token::Token(*) | ||
{ | ||
select token::Token.val<&token::Token>({ | ||
let (ref: &objects::ReaderRef<token::Token>): (&objects::ReaderRef<token::Token>) = Tuple(ref); | ||
BorrowGlobal(Immutable)<token::Token>(objects::get_addr<token::Token>(ref)) | ||
}) | ||
} | ||
} // end 0x42::token | ||
|
||
|
||
============ bytecode verification succeeded ======== |
24 changes: 24 additions & 0 deletions
24
third_party/move/move-compiler-v2/tests/checking/inlining/resources_valid.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,24 @@ | ||
module 0x42::objects { | ||
|
||
struct ReaderRef<phantom T: key> has store { | ||
addr: address | ||
} | ||
|
||
public fun get_addr<T: key>(ref: &ReaderRef<T>): address { | ||
ref.addr | ||
} | ||
|
||
public inline fun reader<T: key>(ref: &ReaderRef<T>): &T { | ||
borrow_global<T>(get_addr(ref)) | ||
} | ||
} | ||
|
||
module 0x42::token { | ||
use 0x42::objects as obj; | ||
|
||
struct Token has key { val: u64 } | ||
|
||
public fun get_value(ref: &obj::ReaderRef<Token>): u64 acquires Token { | ||
obj::reader(ref).val | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
third_party/move/move-compiler-v2/tests/checking/inlining/resources_valid_noacquires.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,12 @@ | ||
|
||
Diagnostics: | ||
error: missing acquires annotation for `Token` | ||
┌─ tests/checking/inlining/resources_valid_noacquires.move:21:16 | ||
│ | ||
12 │ borrow_global<T>(get_addr(ref)) | ||
│ ------------------------------- acquired here | ||
· | ||
21 │ public fun get_value(ref: &obj::ReaderRef<Token>): u64 { | ||
│ ^^^^^^^^^ | ||
22 │ obj::reader(ref).val | ||
│ ---------------- from a call inlined at this callsite |
24 changes: 24 additions & 0 deletions
24
third_party/move/move-compiler-v2/tests/checking/inlining/resources_valid_noacquires.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,24 @@ | ||
module 0x42::objects { | ||
|
||
struct ReaderRef<phantom T: key> has store { | ||
addr: address | ||
} | ||
|
||
public fun get_addr<T: key>(ref: &ReaderRef<T>): address { | ||
ref.addr | ||
} | ||
|
||
public inline fun reader<T: key>(ref: &ReaderRef<T>): &T { | ||
borrow_global<T>(get_addr(ref)) | ||
} | ||
} | ||
|
||
module 0x42::token { | ||
use 0x42::objects as obj; | ||
|
||
struct Token has key { val: u64 } | ||
|
||
public fun get_value(ref: &obj::ReaderRef<Token>): u64 { | ||
obj::reader(ref).val | ||
} | ||
} |
6 changes: 0 additions & 6 deletions
6
third_party/move/move-compiler/tests/move_check/inlining/resources_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
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
24 changes: 24 additions & 0 deletions
24
third_party/move/move-compiler/tests/move_check/inlining/resources_valid.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,24 @@ | ||
module 0x42::objects { | ||
|
||
struct ReaderRef<phantom T: key> has store { | ||
addr: address | ||
} | ||
|
||
public fun get_addr<T: key>(ref: &ReaderRef<T>): address { | ||
ref.addr | ||
} | ||
|
||
public inline fun reader<T: key>(ref: &ReaderRef<T>): &T { | ||
borrow_global<T>(get_addr(ref)) | ||
} | ||
} | ||
|
||
module 0x42::token { | ||
use 0x42::objects as obj; | ||
|
||
struct Token has key { val: u64 } | ||
|
||
public fun get_value(ref: &obj::ReaderRef<Token>): u64 acquires Token { | ||
obj::reader(ref).val | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
third_party/move/move-compiler/tests/move_check/inlining/resources_valid_noacquires.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,6 @@ | ||
error[E04020]: missing acquires annotation | ||
┌─ tests/move_check/inlining/resources_valid_noacquires.move:12:9 | ||
│ | ||
12 │ borrow_global<T>(get_addr(ref)) | ||
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The call acquires '0x42::token::Token', but the 'acquires' list for the current function 'get_value` does not contain this type. It must be present in the calling context's acquires list | ||
|
24 changes: 24 additions & 0 deletions
24
third_party/move/move-compiler/tests/move_check/inlining/resources_valid_noacquires.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,24 @@ | ||
module 0x42::objects { | ||
|
||
struct ReaderRef<phantom T: key> has store { | ||
addr: address | ||
} | ||
|
||
public fun get_addr<T: key>(ref: &ReaderRef<T>): address { | ||
ref.addr | ||
} | ||
|
||
public inline fun reader<T: key>(ref: &ReaderRef<T>): &T { | ||
borrow_global<T>(get_addr(ref)) | ||
} | ||
} | ||
|
||
module 0x42::token { | ||
use 0x42::objects as obj; | ||
|
||
struct Token has key { val: u64 } | ||
|
||
public fun get_value(ref: &obj::ReaderRef<Token>): u64 { | ||
obj::reader(ref).val | ||
} | ||
} |