Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Zekun Wang committed Jun 18, 2024
1 parent 5757427 commit d76d5bf
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 0 deletions.
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;
│ ^^^^^^^^^^
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;
}
}

0 comments on commit d76d5bf

Please sign in to comment.