-
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 5, 2024
1 parent
257508e
commit da23980
Showing
2 changed files
with
171 additions
and
0 deletions.
There are no files selected for viewing
152 changes: 152 additions & 0 deletions
152
third_party/move/move-compiler-v2/tests/unused-assignment/unused_assignment.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,152 @@ | ||
|
||
Diagnostics: | ||
warning: Unused parameter `a`. Consider removing or prefixing with an underscore: `_a` | ||
┌─ tests/unused-assignment/unused_assignment.move:2:13 | ||
│ | ||
2 │ fun foo(a: u8, _b: u8) { | ||
│ ^ | ||
|
||
warning: Unused local variable `y`. Consider removing or prefixing with an underscore: `_y` | ||
┌─ tests/unused-assignment/unused_assignment.move:5:13 | ||
│ | ||
5 │ let y = 0; | ||
│ ^ | ||
|
||
warning: Unused local variable `w`. Consider removing or prefixing with an underscore: `_w` | ||
┌─ tests/unused-assignment/unused_assignment.move:7:13 | ||
│ | ||
7 │ let w = bar(false); | ||
│ ^ | ||
|
||
============ initial bytecode ================ | ||
|
||
[variant baseline] | ||
fun test::bar($t0: bool): u8 { | ||
var $t1: u8 | ||
var $t2: u64 | ||
var $t3: u64 | ||
var $t4: u64 | ||
var $t5: u64 | ||
var $t6: u64 | ||
0: $t2 := 0 | ||
1: if ($t0) goto 2 else goto 7 | ||
2: label L0 | ||
3: $t4 := 1 | ||
4: $t3 := +($t2, $t4) | ||
5: $t2 := infer($t3) | ||
6: goto 11 | ||
7: label L1 | ||
8: $t6 := 2 | ||
9: $t5 := +($t2, $t6) | ||
10: $t2 := infer($t5) | ||
11: label L2 | ||
12: $t1 := 42 | ||
13: return $t1 | ||
} | ||
|
||
|
||
[variant baseline] | ||
fun test::foo($t0: u8, $t1: u8) { | ||
var $t2: u64 | ||
var $t3: u64 | ||
var $t4: u64 | ||
var $t5: u8 | ||
var $t6: bool | ||
0: $t2 := 0 | ||
1: $t4 := 1 | ||
2: $t3 := +($t2, $t4) | ||
3: $t2 := infer($t3) | ||
4: $t6 := false | ||
5: $t5 := test::bar($t6) | ||
6: return () | ||
} | ||
|
||
============ after LiveVarAnalysisProcessor: ================ | ||
|
||
[variant baseline] | ||
fun test::bar($t0: bool): u8 { | ||
var $t1: u8 | ||
var $t2: u64 | ||
var $t3: u64 | ||
var $t4: u64 | ||
var $t5: u64 | ||
var $t6: u64 | ||
# live vars: $t0 | ||
0: $t2 := 0 | ||
# live vars: $t0, $t2 | ||
1: if ($t0) goto 2 else goto 7 | ||
# live vars: $t2 | ||
2: label L0 | ||
# live vars: $t2 | ||
3: $t4 := 1 | ||
# live vars: $t2, $t4 | ||
4: $t3 := +($t2, $t4) | ||
# live vars: $t3 | ||
5: $t2 := infer($t3) | ||
# live vars: | ||
6: goto 11 | ||
# live vars: $t2 | ||
7: label L1 | ||
# live vars: $t2 | ||
8: $t6 := 2 | ||
# live vars: $t2, $t6 | ||
9: $t5 := +($t2, $t6) | ||
# live vars: $t5 | ||
10: $t2 := infer($t5) | ||
# live vars: | ||
11: label L2 | ||
# live vars: | ||
12: $t1 := 42 | ||
# live vars: $t1 | ||
13: return $t1 | ||
} | ||
|
||
|
||
[variant baseline] | ||
fun test::foo($t0: u8, $t1: u8) { | ||
var $t2: u64 | ||
var $t3: u64 | ||
var $t4: u64 | ||
var $t5: u8 | ||
var $t6: bool | ||
# live vars: $t0, $t1 | ||
0: $t2 := 0 | ||
# live vars: $t2 | ||
1: $t4 := 1 | ||
# live vars: $t2, $t4 | ||
2: $t3 := +($t2, $t4) | ||
# live vars: $t3 | ||
3: $t2 := infer($t3) | ||
# live vars: | ||
4: $t6 := false | ||
# live vars: $t6 | ||
5: $t5 := test::bar($t6) | ||
# live vars: | ||
6: return () | ||
} | ||
|
||
|
||
Diagnostics: | ||
warning: Unused assignment to `x`. Consider removing or prefixing with an underscore: `_x` | ||
┌─ tests/unused-assignment/unused_assignment.move:4:9 | ||
│ | ||
4 │ x = x + 1; | ||
│ ^^^^^^^^^ | ||
|
||
warning: Unused assignment to `w`. Consider removing or prefixing with an underscore: `_w` | ||
┌─ tests/unused-assignment/unused_assignment.move:7:17 | ||
│ | ||
7 │ let w = bar(false); | ||
│ ^^^^^^^^^^ | ||
|
||
warning: Unused assignment to `y`. Consider removing or prefixing with an underscore: `_y` | ||
┌─ tests/unused-assignment/unused_assignment.move:13:13 | ||
│ | ||
13 │ y = y + 1; | ||
│ ^^^^^^^^^ | ||
|
||
warning: Unused assignment to `y`. Consider removing or prefixing with an underscore: `_y` | ||
┌─ tests/unused-assignment/unused_assignment.move:15:13 | ||
│ | ||
15 │ y = y + 2; | ||
│ ^^^^^^^^^ |
19 changes: 19 additions & 0 deletions
19
third_party/move/move-compiler-v2/tests/unused-assignment/unused_assignment.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,19 @@ | ||
module 0x42::test { | ||
fun foo(a: u8, _b: u8) { | ||
let x = 0; | ||
x = x + 1; | ||
let y = 0; | ||
let _z = 42; | ||
let w = bar(false); | ||
} | ||
|
||
fun bar(x: bool): u8 { | ||
let y = 0; | ||
if (x) { | ||
y = y + 1; | ||
} else { | ||
y = y + 2; | ||
}; | ||
42 | ||
} | ||
} |