-
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 18, 2024
1 parent
5757427
commit d76d5bf
Showing
2 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
third_party/move/move-compiler-v2/tests/unused-assignment/unused_in_pattern.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,81 @@ | ||
|
||
Diagnostics: | ||
warning: Unused local variable `x`. Consider removing or prefixing with an underscore: `_x` | ||
┌─ tests/unused-assignment/unused_in_pattern.move:20:11 | ||
│ | ||
20 │ let S { x, y } = s; | ||
│ ^ | ||
|
||
warning: Unused local variable `y`. Consider removing or prefixing with an underscore: `_y` | ||
┌─ tests/unused-assignment/unused_in_pattern.move:20:14 | ||
│ | ||
20 │ let S { x, y } = s; | ||
│ ^ | ||
|
||
warning: Unused local variable `z`. Consider removing or prefixing with an underscore: `_z` | ||
┌─ tests/unused-assignment/unused_in_pattern.move:26:7 | ||
│ | ||
26 │ let z: S; | ||
│ ^ | ||
|
||
warning: Unused local variable `x`. Consider removing or prefixing with an underscore: `_x` | ||
┌─ tests/unused-assignment/unused_in_pattern.move:33:18 | ||
│ | ||
33 │ let T { z: S { x, y } } = t; | ||
│ ^ | ||
|
||
warning: Unused local variable `y`. Consider removing or prefixing with an underscore: `_y` | ||
┌─ tests/unused-assignment/unused_in_pattern.move:33:21 | ||
│ | ||
33 │ let T { z: S { x, y } } = t; | ||
│ ^ | ||
|
||
|
||
Diagnostics: | ||
warning: Unused assignment to `x`. Consider removing or prefixing with an underscore: `_x` | ||
┌─ tests/unused-assignment/unused_in_pattern.move:15:3 | ||
│ | ||
15 │ S { x, y } = s; | ||
│ ^^^^^^^^^^ | ||
|
||
warning: Unused assignment to `y`. Consider removing or prefixing with an underscore: `_y` | ||
┌─ tests/unused-assignment/unused_in_pattern.move:15:3 | ||
│ | ||
15 │ S { x, y } = s; | ||
│ ^^^^^^^^^^ | ||
|
||
warning: Unused assignment to `x`. Consider removing or prefixing with an underscore: `_x` | ||
┌─ tests/unused-assignment/unused_in_pattern.move:20:7 | ||
│ | ||
20 │ let S { x, y } = s; | ||
│ ^^^^^^^^^^ | ||
|
||
warning: Unused assignment to `y`. Consider removing or prefixing with an underscore: `_y` | ||
┌─ tests/unused-assignment/unused_in_pattern.move:20:7 | ||
│ | ||
20 │ let S { x, y } = s; | ||
│ ^^^^^^^^^^ | ||
|
||
warning: Unused assignment to `x`. Consider removing or prefixing with an underscore: `_x` | ||
┌─ tests/unused-assignment/unused_in_pattern.move:28:10 | ||
│ | ||
28 │ T { z: S { x, y } } = t; | ||
│ ^^^^^^^^^^ | ||
|
||
warning: Unused assignment to `y`. Consider removing or prefixing with an underscore: `_y` | ||
┌─ tests/unused-assignment/unused_in_pattern.move:28:10 | ||
│ | ||
28 │ T { z: S { x, y } } = t; | ||
│ ^^^^^^^^^^ | ||
|
||
warning: Unused assignment to `x`. Consider removing or prefixing with an underscore: `_x` | ||
┌─ tests/unused-assignment/unused_in_pattern.move:33:14 | ||
│ | ||
33 │ let T { z: S { x, y } } = t; | ||
│ ^^^^^^^^^^ | ||
|
||
warning: Unused assignment to `y`. Consider removing or prefixing with an underscore: `_y` | ||
┌─ tests/unused-assignment/unused_in_pattern.move:33:14 | ||
│ | ||
33 │ let T { z: S { x, y } } = t; | ||
│ ^^^^^^^^^^ |
40 changes: 40 additions & 0 deletions
40
third_party/move/move-compiler-v2/tests/unused-assignment/unused_in_pattern.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,40 @@ | ||
module 0x42::test { | ||
struct S { | ||
x: u8, | ||
y: bool, | ||
} | ||
|
||
struct T { | ||
z: S, | ||
} | ||
|
||
fun unused_assign_in_pattern() { | ||
let x; | ||
let y; | ||
let s = S { x: 42, y: true }; | ||
S { x, y } = s; | ||
} | ||
|
||
fun unused_decl_in_pattern() { | ||
let s = S { x: 42, y: true }; | ||
let S { x, y } = s; | ||
} | ||
|
||
fun unused_assign_in_nested_pattern() { | ||
let x; | ||
let y; | ||
let z: S; | ||
let t = T { z: S { x: 42, y: true } }; | ||
T { z: S { x, y } } = t; | ||
} | ||
|
||
fun unused_decl_in_nested_pattern() { | ||
let t = T { z: S { x: 42, y: true } }; | ||
let T { z: S { x, y } } = t; | ||
} | ||
|
||
fun unused_in_pattern_ok() { | ||
let s = S { x: 42, y: true }; | ||
let S { x: _x, y: _y }= s; | ||
} | ||
} |