Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Zekun Wang committed Sep 26, 2024
1 parent 903542d commit 7108561
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
28 changes: 28 additions & 0 deletions third_party/move/move-compiler-v2/tests/op-equal/invalid6.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// -- Model dump before bytecode pipeline
module 0x42::test {
private fun inc_new(x: &u256) {
{
let $t: &u256 = x;
$t = Add<u256>(Deref($t), 1)
};
Tuple()
}
private fun inc_old(x: &u256) {
x = Add<u256>(Deref(x), 1);
Tuple()
}
} // end 0x42::test


Diagnostics:
error: expected `&mut` but found `&u256`
┌─ tests/op-equal/invalid6.move:3:10
3 │ *x = *x + 1;
│ ^

error: expected `&mut` but found `&u256`
┌─ tests/op-equal/invalid6.move:7:11
7 │ *x += 1;
│ ^
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module 0x42::test {
fun inc_old(x: &u256) {
*x = *x + 1;
}

fun inc_new(x: &u256) {
*x += 1;
}
}

0 comments on commit 7108561

Please sign in to comment.