[SMTChecker] Support enums

This commit is contained in:
Leonardo Alt
2019-03-07 15:15:12 +01:00
parent 7241aa755c
commit 02d0e609b9
17 changed files with 180 additions and 6 deletions
@@ -8,5 +8,4 @@ contract C
}
// ----
// Warning: (86-101): Assertion checker does not yet support this expression.
// Warning: (86-101): Internal error: Expression undefined for SMT solver.
// Warning: (79-106): Assertion violation happens here
@@ -0,0 +1,14 @@
pragma experimental SMTChecker;
contract C
{
enum D { Left, Right }
function f(uint x) public pure {
require(x == 0);
D _a = D(x);
assert(_a == D.Left);
}
}
// ----
// Warning: (132-136): Type conversion is not yet fully supported and might yield false positives.
// Warning: (140-160): Assertion violation happens here
@@ -0,0 +1,12 @@
pragma experimental SMTChecker;
contract C
{
enum D { Left, Right }
function f(D _a) public pure {
uint x = uint(_a);
assert(x < 10);
}
}
// ----
// Warning: (113-121): Type conversion is not yet fully supported and might yield false positives.
@@ -0,0 +1,12 @@
pragma experimental SMTChecker;
contract C
{
enum D { Left, Right }
D d;
function f(D _a) public {
require(_a == D.Left);
d = D.Right;
assert(d != _a);
}
}
@@ -0,0 +1,14 @@
pragma experimental SMTChecker;
contract C
{
enum D { Left, Right }
D d;
function f(D _a) public {
require(_a == D.Left);
d = D.Left;
assert(d != _a);
}
}
// ----
// Warning: (144-159): Assertion violation happens here
@@ -0,0 +1,15 @@
pragma experimental SMTChecker;
library L
{
enum D { Left, Right }
}
contract C
{
enum E { Left, Right }
function f(E _d) internal pure {
_d = E.Left;
assert(_d == E.Left);
}
}
@@ -0,0 +1,17 @@
pragma experimental SMTChecker;
library L
{
enum D { Left, Right }
}
contract C
{
enum E { Left, Right }
function f(E _d) internal pure {
_d = E.Right;
assert(_d == E.Left);
}
}
// ----
// Warning: (161-181): Assertion violation happens here
@@ -0,0 +1,17 @@
pragma experimental SMTChecker;
contract C
{
enum D { Left, Right }
struct S { uint x; D d; }
function f(S memory s) internal pure {
s.d = D.Left;
assert(s.d == D.Left);
}
}
// ----
// Warning: (109-119): Assertion checker does not yet support the type of this variable.
// Warning: (139-142): Assertion checker does not yet support this expression.
// Warning: (139-151): Assertion checker does not yet implement such assignments.
// Warning: (162-165): Assertion checker does not yet support this expression.
// Warning: (155-176): Assertion violation happens here
@@ -0,0 +1,13 @@
pragma experimental SMTChecker;
contract C
{
enum D { Left, Right }
D d;
function f(D _d) public {
d = _d;
assert(d != _d);
}
}
// ----
// Warning: (115-130): Assertion violation happens here
@@ -0,0 +1,12 @@
pragma experimental SMTChecker;
contract C
{
enum D { Left, Right }
D d;
function f(D _a, D _b) public view {
require(_a == _b);
require(_a == d);
assert(d == _b);
}
}
@@ -9,6 +9,4 @@ contract C
// ----
// Warning: (117-133): Assertion checker does not yet support this expression.
// Warning: (137-153): Assertion checker does not yet support this expression.
// Warning: (117-133): Internal error: Expression undefined for SMT solver.
// Warning: (137-153): Internal error: Expression undefined for SMT solver.
// Warning: (110-154): Assertion violation happens here