-
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.
- Loading branch information
Zekun Wang
committed
Jun 19, 2024
1 parent
f26cebf
commit 5d5d645
Showing
11 changed files
with
308 additions
and
4 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
third_party/move/move-compiler-v2/tests/unused-assignment/v1-commands/mixed_lvalue.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,13 @@ | ||
|
||
Diagnostics: | ||
error: invalid assignment | ||
┌─ tests/unused-assignment/v1-commands/mixed_lvalue.move:14:19 | ||
│ | ||
14 │ (_, _, _, s.f) = four(); | ||
│ ^^^ Invalid assignment syntax. Expected: a local, a field write, or a deconstructing assignment | ||
|
||
error: invalid assignment | ||
┌─ tests/unused-assignment/v1-commands/mixed_lvalue.move:15:19 | ||
│ | ||
15 │ (_, _, _, *r_ref) = four(); | ||
│ ^^^^^^ Invalid assignment syntax. Expected: a local, a field write, or a deconstructing assignment |
17 changes: 17 additions & 0 deletions
17
third_party/move/move-compiler-v2/tests/unused-assignment/v1-commands/mixed_lvalue.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,17 @@ | ||
module 0x8675309::A { | ||
|
||
struct S has drop { f: u64 } | ||
|
||
fun four(): (u64, u64, u64, u64) { | ||
(0, 1, 2, 3) | ||
} | ||
|
||
public fun mixed() { | ||
let r = 0; | ||
let r_ref = &mut r; | ||
let s = S { f: 0 }; | ||
|
||
(_, _, _, s.f) = four(); | ||
(_, _, _, *r_ref) = four(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...party/move/move-compiler-v2/tests/unused-assignment/v1-locals/assign_partial_resource.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,25 @@ | ||
|
||
Diagnostics: | ||
warning: Unused assignment to `r`. Consider removing or prefixing with an underscore: `_r` | ||
┌─ tests/unused-assignment/v1-locals/assign_partial_resource.move:6:21 | ||
│ | ||
6 │ if (cond) { r = R{}; }; | ||
│ ^^^^^^^ | ||
|
||
warning: Unused assignment to `r`. Consider removing or prefixing with an underscore: `_r` | ||
┌─ tests/unused-assignment/v1-locals/assign_partial_resource.move:13:29 | ||
│ | ||
13 │ if (cond) {} else { r = R{}; }; | ||
│ ^^^^^^^ | ||
|
||
warning: Unused assignment to `r`. Consider removing or prefixing with an underscore: `_r` | ||
┌─ tests/unused-assignment/v1-locals/assign_partial_resource.move:20:24 | ||
│ | ||
20 │ while (cond) { r = R{} }; | ||
│ ^^^^^^^ | ||
|
||
warning: Unused assignment to `r`. Consider removing or prefixing with an underscore: `_r` | ||
┌─ tests/unused-assignment/v1-locals/assign_partial_resource.move:27:16 | ||
│ | ||
27 │ loop { r = R{} } | ||
│ ^^^^^^^ |
34 changes: 34 additions & 0 deletions
34
...arty/move/move-compiler-v2/tests/unused-assignment/v1-locals/assign_partial_resource.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,34 @@ | ||
module 0x8675309::M { | ||
struct R {} | ||
|
||
fun t1(cond: bool) { | ||
let r: R; | ||
if (cond) { r = R{}; }; | ||
r = R{}; | ||
R{} = r; | ||
} | ||
|
||
fun t2(cond: bool) { | ||
let r: R; | ||
if (cond) {} else { r = R{}; }; | ||
r = R{}; | ||
R{} = r; | ||
} | ||
|
||
fun t3(cond: bool) { | ||
let r: R; | ||
while (cond) { r = R{} }; | ||
r = R{}; | ||
R{} = r; | ||
} | ||
|
||
fun t4() { | ||
let r: R; | ||
loop { r = R{} } | ||
} | ||
|
||
fun t5<T>(cond: bool, x: T, y: T): (T, T) { | ||
if (cond) { x = y }; | ||
(x, y) | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
third_party/move/move-compiler-v2/tests/unused-assignment/v1-locals/assign_resource.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,13 @@ | ||
|
||
Diagnostics: | ||
warning: Unused assignment to `r`. Consider removing or prefixing with an underscore: `_r` | ||
┌─ tests/unused-assignment/v1-locals/assign_resource.move:5:17 | ||
│ | ||
5 │ let r = R{}; | ||
│ ^^^ | ||
|
||
warning: Unused assignment to `r`. Consider removing or prefixing with an underscore: `_r` | ||
┌─ tests/unused-assignment/v1-locals/assign_resource.move:29:17 | ||
│ | ||
29 │ let r = R{}; | ||
│ ^^^ |
37 changes: 37 additions & 0 deletions
37
third_party/move/move-compiler-v2/tests/unused-assignment/v1-locals/assign_resource.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,37 @@ | ||
module 0x8675309::M { | ||
struct R {} | ||
|
||
fun t0() { | ||
let r = R{}; | ||
r = R{}; | ||
R{} = r; | ||
} | ||
|
||
fun t1(cond: bool) { | ||
let r = R{}; | ||
if (cond) { r = R{}; }; | ||
R{} = r; | ||
} | ||
|
||
fun t2(cond: bool) { | ||
let r = R{}; | ||
if (cond) {} else { r = R{}; }; | ||
R{} = r; | ||
} | ||
|
||
fun t3(cond: bool) { | ||
let r = R{}; | ||
while (cond) { r = R{} }; | ||
R{} = r; | ||
} | ||
|
||
fun t4() { | ||
let r = R{}; | ||
loop { r = R{}; R {} = r } | ||
} | ||
|
||
fun t5<T>(x: T, y: T): T { | ||
x = y; | ||
x | ||
} | ||
} |
131 changes: 131 additions & 0 deletions
131
...arty/move/move-compiler-v2/tests/unused-assignment/v1-locals/struct_use_before_assign.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,131 @@ | ||
|
||
Diagnostics: | ||
warning: Unused local variable `z`. Consider removing or prefixing with an underscore: `_z` | ||
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:8:13 | ||
│ | ||
8 │ let z = y; | ||
│ ^ | ||
|
||
warning: Unused local variable `q`. Consider removing or prefixing with an underscore: `_q` | ||
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:9:13 | ||
│ | ||
9 │ let q = x; | ||
│ ^ | ||
|
||
warning: Unused local variable `z`. Consider removing or prefixing with an underscore: `_z` | ||
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:17:13 | ||
│ | ||
17 │ let z = y; | ||
│ ^ | ||
|
||
warning: Unused local variable `q`. Consider removing or prefixing with an underscore: `_q` | ||
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:18:13 | ||
│ | ||
18 │ let q = x; | ||
│ ^ | ||
|
||
warning: Unused local variable `z`. Consider removing or prefixing with an underscore: `_z` | ||
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:24:13 | ||
│ | ||
24 │ let z = y; | ||
│ ^ | ||
|
||
warning: Unused local variable `q`. Consider removing or prefixing with an underscore: `_q` | ||
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:25:13 | ||
│ | ||
25 │ let q = x; | ||
│ ^ | ||
|
||
warning: Unused local variable `z`. Consider removing or prefixing with an underscore: `_z` | ||
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:30:13 | ||
│ | ||
30 │ let z = y; | ||
│ ^ | ||
|
||
warning: Unused local variable `q`. Consider removing or prefixing with an underscore: `_q` | ||
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:31:13 | ||
│ | ||
31 │ let q = x; | ||
│ ^ | ||
|
||
|
||
Diagnostics: | ||
error: use of unassigned local `g` | ||
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:6:17 | ||
│ | ||
6 │ let r = R { f: 3, g }; | ||
│ ^^^^^^^^^^^^^ | ||
|
||
error: use of unassigned local `y0` | ||
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:15:17 | ||
│ | ||
15 │ let r = R { f: x0, g: y0 }; | ||
│ ^^^^^^^^^^^^^^^^^^ | ||
|
||
error: use of unassigned local `r` | ||
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:23:13 | ||
│ | ||
23 │ let R { f: x, g: y } = r; | ||
│ ^^^^^^^^^^^^^^^^ | ||
|
||
error: use of unassigned local `y` | ||
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:30:17 | ||
│ | ||
30 │ let z = y; | ||
│ ^ | ||
|
||
error: use of unassigned local `x` | ||
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:31:17 | ||
│ | ||
31 │ let q = x; | ||
│ ^ | ||
|
||
|
||
Diagnostics: | ||
warning: Unused assignment to `z`. Consider removing or prefixing with an underscore: `_z` | ||
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:8:17 | ||
│ | ||
8 │ let z = y; | ||
│ ^ | ||
|
||
warning: Unused assignment to `q`. Consider removing or prefixing with an underscore: `_q` | ||
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:9:17 | ||
│ | ||
9 │ let q = x; | ||
│ ^ | ||
|
||
warning: Unused assignment to `z`. Consider removing or prefixing with an underscore: `_z` | ||
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:17:17 | ||
│ | ||
17 │ let z = y; | ||
│ ^ | ||
|
||
warning: Unused assignment to `q`. Consider removing or prefixing with an underscore: `_q` | ||
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:18:17 | ||
│ | ||
18 │ let q = x; | ||
│ ^ | ||
|
||
warning: Unused assignment to `z`. Consider removing or prefixing with an underscore: `_z` | ||
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:24:17 | ||
│ | ||
24 │ let z = y; | ||
│ ^ | ||
|
||
warning: Unused assignment to `q`. Consider removing or prefixing with an underscore: `_q` | ||
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:25:17 | ||
│ | ||
25 │ let q = x; | ||
│ ^ | ||
|
||
warning: Unused assignment to `z`. Consider removing or prefixing with an underscore: `_z` | ||
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:30:17 | ||
│ | ||
30 │ let z = y; | ||
│ ^ | ||
|
||
warning: Unused assignment to `q`. Consider removing or prefixing with an underscore: `_q` | ||
┌─ tests/unused-assignment/v1-locals/struct_use_before_assign.move:31:17 | ||
│ | ||
31 │ let q = x; | ||
│ ^ |
33 changes: 33 additions & 0 deletions
33
...rty/move/move-compiler-v2/tests/unused-assignment/v1-locals/struct_use_before_assign.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,33 @@ | ||
module 0x876543::M { | ||
struct R { f: u64, g: u64 } | ||
|
||
fun main() { | ||
let g: u64; | ||
let r = R { f: 3, g }; | ||
let R { f: x, g: y } = r; | ||
let z = y; | ||
let q = x; | ||
} | ||
|
||
fun main2() { | ||
let x0: u64 = 0; | ||
let y0: u64; | ||
let r = R { f: x0, g: y0 }; | ||
let R { f: x, g: y } = r; | ||
let z = y; | ||
let q = x; | ||
} | ||
|
||
fun main3() { | ||
let r: R; | ||
let R { f: x, g: y } = r; | ||
let z = y; | ||
let q = x; | ||
} | ||
|
||
fun main4() { | ||
let R { f: x, g: y }; | ||
let z = y; | ||
let q = x; | ||
} | ||
} |
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
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