[SMTChecker] Fixing conversion from StringLiteral to FixedBytes

This commit is contained in:
Martin Blicha
2020-12-07 19:30:51 +01:00
parent 51e27dd3d3
commit ff0c794674
9 changed files with 60 additions and 19 deletions
@@ -1,7 +1,11 @@
pragma experimental SMTChecker;
contract C {
function f() public pure returns (byte) {
return (byte("") & (""));
}
function f() public pure {
assert(byte("") & ("") == byte(0)); // should hold
assert(byte(0xAA) & byte(0x55) == byte(0)); // should hold
assert(byte(0xFF) & byte(0xAA) == byte(0xAA)); // should hold
assert(byte(0xFF) & byte(0xAA) == byte(0)); // should fail
}
}
// ----
// Warning 6328: (253-295): CHC: Assertion violation happens here.
@@ -9,4 +9,4 @@ contract C {
}
}
// ----
// Warning 6328: (175-198): CHC: Assertion violation happens here.
// Warning 6328: (133-156): CHC: Assertion violation happens here.
@@ -1,7 +1,11 @@
pragma experimental SMTChecker;
contract C {
function f() public pure returns (byte) {
return (byte(0x0F) | (byte(0xF0)));
}
function f() public pure returns (byte) {
byte b = (byte(0x0F) | (byte(0xF0)));
assert(b == byte(0xFF)); // should hold
assert(b == byte(0x00)); // should fail
return b;
}
}
// ----
// Warning 6328: (172-195): CHC: Assertion violation happens here.
@@ -1,8 +1,11 @@
pragma experimental SMTChecker;
contract Simp {
function f3() public pure returns (byte) {
bytes memory y = "def";
return y[0] ^ "e";
}
function f3() public pure returns (byte) {
bytes memory y = "def";
assert(y[0] ^ "e" != byte(0)); // should hold
assert(y[1] ^ "e" != byte(0)); // should fail
return y[0];
}
}
// ----
// Warning 6328: (168-197): CHC: Assertion violation happens here.
@@ -0,0 +1,12 @@
pragma experimental SMTChecker;
contract C {
function f() public pure {
bytes memory b = bytes(hex"ffff");
assert(b.length == 2); // should hold
assert(b[0] == byte(uint8(255))); // should hold
assert(b[1] == byte(uint8(100))); // should fail
}
}
// ----
// Warning 6328: (204-236): CHC: Assertion violation happens here.
@@ -0,0 +1,10 @@
pragma experimental SMTChecker;
contract C {
function f() public pure {
assert(bytes4(hex"0000ffff") == bytes4(hex"ffff")); // should fail
assert(bytes4(hex"ffff0000") == bytes4(hex"ffff")); // should hold
}
}
// ----
// Warning 6328: (76-126): CHC: Assertion violation happens here.