Skip to content

Commit

Permalink
[move-prover] add a test case for warnings on uninstanted invariants
Browse files Browse the repository at this point in the history
Closes: #9545
  • Loading branch information
meng-xu-cs authored and bors-libra committed Oct 27, 2021
1 parent 78a6671 commit e6ce2a8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
warning: Failed to instantiate all type parameters in this global invariant
┌─ tests/sources/functional/uninst_global_invariant.move:11:9
7 │ move_to(&account, S1 {});
│ ------- When instrumenting the global invariant here
·
11 │ invariant<T> exists<S1>(@0x42) ==> exists<S2<T>>(@0x42);
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module 0x42::Test {
struct S1 has key, store {}

struct S2<T: store> has key, store { t: T }

fun foo(account: signer) {
move_to(&account, S1 {});
}

spec module {
invariant<T> exists<S1>(@0x42) ==> exists<S2<T>>(@0x42);

// When applying invariant I to function foo, we cannot
// find a valid instantiation for the type parameter `T`.
// therefore, this global invariant cannot be checked.
}
}

0 comments on commit e6ce2a8

Please sign in to comment.