Update tests

This commit is contained in:
Alex Beregszaszi 2020-12-14 17:34:40 +00:00
parent 15237c8404
commit edbdff8619
71 changed files with 214 additions and 219 deletions

View File

@ -4,7 +4,7 @@ Warning: SPDX license identifier not provided in source file. Before publishing,
Error: No visibility specified. Did you intend to add "public"?
--> too_long_line_multiline/input.sol:2:5:
|
2 | function f() returns (byte _b, byte ... _b7, bytes22 _b22, bytes32 _b32) {
2 | function f() returns (bytes1 _b, by ... _b7, bytes22 _b22, bytes32 _b32) {
| ^ (Relevant source part starts here and spans across multiple lines).
Warning: Source file does not specify required compiler version!

View File

@ -1,5 +1,5 @@
contract C {
function f() returns (byte _b, bytes2 _b2, bytes3 _b3, bytes memory _blit, bytes5 _b5, bytes6 _b6, string memory _str, bytes7 _b7, bytes22 _b22, bytes32 _b32) {
function f() returns (bytes1 _b, bytes2 _b2, bytes3 _b3, bytes memory _blit, bytes5 _b5, bytes6 _b6, string memory _str, bytes7 _b7, bytes22 _b22, bytes32 _b32) {
_b = 0x12;
_b2 = 0x1223;
_b5 = hex"043245";

View File

@ -257,7 +257,7 @@ library RLP {
/// RLPItem is a list.
/// @param self The RLPItem.
/// @return data The decoded string.
function toByte(RLPItem memory self) internal view returns (byte data) {
function toByte(RLPItem memory self) internal view returns (bytes1 data) {
if(!isData(self))
revert();
(uint rStartPos, uint len) = _decode(self);
@ -267,7 +267,7 @@ library RLP {
assembly {
temp := byte(0, mload(rStartPos))
}
return byte(temp);
return bytes1(temp);
}
/// @dev Decode an RLPItem into an int. This will not work if the

View File

@ -2037,7 +2037,7 @@ BOOST_AUTO_TEST_CASE(event_indexed_string)
for (uint i = 0; i < 90; i++)
bytes(x).push(0);
for (uint8 i = 0; i < 90; i++)
bytes(x)[i] = byte(i);
bytes(x)[i] = bytes1(i);
y[0] = 4;
y[1] = 5;
y[2] = 6;
@ -3421,9 +3421,9 @@ BOOST_AUTO_TEST_CASE(library_call)
BOOST_AUTO_TEST_CASE(library_function_external)
{
char const* sourceCode = R"(
library Lib { function m(bytes calldata b) external pure returns (byte) { return b[2]; } }
library Lib { function m(bytes calldata b) external pure returns (bytes1) { return b[2]; } }
contract Test {
function f(bytes memory b) public pure returns (byte) {
function f(bytes memory b) public pure returns (bytes1) {
return Lib.m(b);
}
}
@ -3786,7 +3786,7 @@ BOOST_AUTO_TEST_CASE(short_strings)
if (data1[0] != "1") return 10;
if (data1[4] != "4") return 11;
for (uint i = 0; i < data1.length; i ++)
data1[i] = byte(uint8(i * 3));
data1[i] = bytes1(uint8(i * 3));
if (uint8(data1[4]) != 4 * 3) return 12;
if (uint8(data1[67]) != 67 * 3) return 13;
// change length: long -> short

View File

@ -679,7 +679,7 @@ BOOST_AUTO_TEST_CASE(byte_access)
char const* sourceCode = R"(
contract C
{
function f(bytes32 x) public returns (byte r)
function f(bytes32 x) public returns (bytes1 r)
{
assembly { r := and(byte(x, 31), 0xff) }
}

View File

@ -491,6 +491,7 @@ BOOST_AUTO_TEST_CASE(keyword_is_reserved)
"alias",
"apply",
"auto",
"byte",
"case",
"copyof",
"default",

View File

@ -51,7 +51,6 @@ BOOST_AUTO_TEST_CASE(uint_types)
BOOST_AUTO_TEST_CASE(byte_types)
{
BOOST_CHECK(*TypeProvider::fromElementaryTypeName(ElementaryTypeNameToken(Token::Byte, 0, 0)) == *TypeProvider::fixedBytes(1));
for (unsigned i = 1; i <= 32; i++)
BOOST_CHECK(*TypeProvider::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, i, 0)) == *TypeProvider::fixedBytes(i));
}
@ -162,7 +161,7 @@ BOOST_AUTO_TEST_CASE(type_identifiers)
StringLiteralType(Literal(++id, SourceLocation{}, Token::StringLiteral, make_shared<string>("abc - def"))).identifier(),
"t_stringliteral_196a9142ee0d40e274a6482393c762b16dd8315713207365e1e13d8d85b74fc4"
);
BOOST_CHECK_EQUAL(TypeProvider::fromElementaryTypeName("byte")->identifier(), "t_bytes1");
BOOST_CHECK_EQUAL(TypeProvider::fromElementaryTypeName("bytes1")->identifier(), "t_bytes1");
BOOST_CHECK_EQUAL(TypeProvider::fromElementaryTypeName("bytes8")->identifier(), "t_bytes8");
BOOST_CHECK_EQUAL(TypeProvider::fromElementaryTypeName("bytes32")->identifier(), "t_bytes32");
BOOST_CHECK_EQUAL(TypeProvider::fromElementaryTypeName("bool")->identifier(), "t_bool");

View File

@ -1,11 +1,11 @@
contract C {
function f(uint a, bytes memory b, uint c)
public pure returns (uint, uint, byte, uint) {
public pure returns (uint, uint, bytes1, uint) {
return (a, b.length, b[3], c);
}
function f_external(uint a, bytes calldata b, uint c)
external pure returns (uint, uint, byte, uint) {
external pure returns (uint, uint, bytes1, uint) {
return (a, b.length, b[3], c);
}
}

View File

@ -2,11 +2,11 @@ contract C {
function f(bytes memory a, bytes calldata b, uint[] memory c)
external
pure
returns (uint, byte, uint, byte, uint, uint)
returns (uint, bytes1, uint, bytes1, uint, uint)
{
return (a.length, a[1], b.length, b[2], c.length, c[3]);
}
function g() public returns (uint, byte, uint, byte, uint, uint) {
function g() public returns (uint, bytes1, uint, bytes1, uint, uint) {
uint[] memory x = new uint[](4);
x[3] = 7;
return this.f("abc", "def", x);

View File

@ -1,13 +1,13 @@
pragma abicoder v2;
pragma abicoder v2;
contract C {
function f(uint a, bytes memory b, uint c)
public pure returns (uint, uint, byte, uint) {
public pure returns (uint, uint, bytes1, uint) {
return (a, b.length, b[3], c);
}
function f_external(uint a, bytes calldata b, uint c)
external pure returns (uint, uint, byte, uint) {
external pure returns (uint, uint, bytes1, uint) {
return (a, b.length, b[3], c);
}
}

View File

@ -1,14 +1,14 @@
pragma abicoder v2;
pragma abicoder v2;
contract C {
function f(bytes memory a, bytes calldata b, uint[] memory c)
external
pure
returns (uint, byte, uint, byte, uint, uint)
returns (uint, bytes1, uint, bytes1, uint, uint)
{
return (a.length, a[1], b.length, b[2], c.length, c[3]);
}
function g() public returns (uint, byte, uint, byte, uint, uint) {
function g() public returns (uint, bytes1, uint, bytes1, uint, uint) {
uint[] memory x = new uint[](4);
x[3] = 7;
return this.f("abc", "def", x);

View File

@ -1,5 +1,5 @@
contract c {
byte[10] data1;
bytes1[10] data1;
bytes2[32] data2;
function test() public returns (uint check, uint res1, uint res2) {
uint i;
@ -7,7 +7,7 @@ contract c {
data2[i] = 0xffff;
check = uint(uint16(data2[31])) * 0x10000 | uint(uint16(data2[14]));
for (i = 0; i < data1.length; ++i)
data1[i] = byte(uint8(1 + i));
data1[i] = bytes1(uint8(1 + i));
data2 = data1;
for (i = 0; i < 16; ++i)
res1 |= uint(uint16(data2[i])) * 0x10000**i;

View File

@ -1,6 +1,6 @@
contract C {
bytes s;
function f() external returns (byte) {
function f() external returns (bytes1) {
bytes memory data = "abcd";
s = data;
return s[0];

View File

@ -1,6 +1,6 @@
contract C {
bytes s = "abcd";
function f() external returns (byte) {
function f() external returns (bytes1) {
bytes memory data = s;
return data[0];
}

View File

@ -4,7 +4,7 @@ contract c {
function f(uint len) public returns (bytes memory) {
bytes memory x = new bytes(len);
for (uint i = 0; i < len; i++)
x[i] = byte(uint8(i));
x[i] = bytes1(uint8(i));
a = x;
for (uint i = 0; i < len; i++)
assert(a[i] == x[i]);

View File

@ -1,6 +1,6 @@
contract C {
bytes s;
function f(bytes calldata data) external returns (byte) {
function f(bytes calldata data) external returns (bytes1) {
s = data;
return s[0];
}

View File

@ -1,7 +1,7 @@
contract C {
bytes data;
bytes otherData;
function fromMemory() public returns (byte) {
function fromMemory() public returns (bytes1) {
bytes memory t;
uint[2] memory x;
x[0] = type(uint).max;
@ -9,12 +9,12 @@ contract C {
data.push();
return data[0];
}
function fromCalldata(bytes calldata x) public returns (byte) {
function fromCalldata(bytes calldata x) public returns (bytes1) {
data = x;
data.push();
return data[0];
}
function fromStorage() public returns (byte) {
function fromStorage() public returns (bytes1) {
// zero-length but dirty higher order bits
assembly { sstore(otherData.slot, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00) }
data = otherData;

View File

@ -1,10 +1,10 @@
contract Main {
function f(bytes memory _s1, uint i1, uint i2, uint i3) public returns (byte c1, byte c2, byte c3) {
function f(bytes memory _s1, uint i1, uint i2, uint i3) public returns (bytes1 c1, bytes1 c2, bytes1 c3) {
c1 = _s1[i1];
c2 = intern(_s1, i2);
c3 = internIndirect(_s1)[i3];
}
function intern(bytes memory _s1, uint i) public returns (byte c) {
function intern(bytes memory _s1, uint i) public returns (bytes1 c) {
return _s1[i];
}
function internIndirect(bytes memory _s1) public returns (bytes memory) {

View File

@ -12,7 +12,7 @@ contract C {
function abiEncode() public view returns (bytes memory) { return x; }
function abiEncodePacked() public view returns (bytes memory) { return abi.encodePacked(x); }
function copyToMemory() public view returns (bytes memory m) { m = x; }
function indexAccess() public view returns (byte) { return x[0]; }
function indexAccess() public view returns (bytes1) { return x[0]; }
function assignTo() public { x = "def"; }
function assignToLong() public { x = "1234567890123456789012345678901234567"; }
function copyToStorage() public { y = x; }

View File

@ -5,9 +5,9 @@ contract c {
bytes data;
function test() public returns (bool) {
for (uint8 i = 0; i <= 40; i++)
data.push(byte(i+1));
data.push(bytes1(i+1));
for (int8 j = 40; j >= 0; j--) {
require(data[uint8(j)] == byte(uint8(j+1)));
require(data[uint8(j)] == bytes1(uint8(j+1)));
require(data.length == uint8(j+1));
data.pop();
}

View File

@ -2,7 +2,7 @@ contract CalldataTest {
function test(bytes calldata x) public returns (bytes calldata) {
return x;
}
function tester(bytes calldata x) public returns (byte) {
function tester(bytes calldata x) public returns (bytes1) {
return this.test(x)[2];
}
}

View File

@ -1,8 +1,8 @@
contract C {
function f(bytes calldata b, uint i) internal pure returns (byte) {
function f(bytes calldata b, uint i) internal pure returns (bytes1) {
return b[i];
}
function f(uint, bytes calldata b, uint) external pure returns (byte) {
function f(uint, bytes calldata b, uint) external pure returns (bytes1) {
return f(b, 2);
}
}

View File

@ -1,15 +1,15 @@
contract C {
function(bytes calldata) returns (byte) x;
function(bytes calldata) returns (bytes1) x;
constructor() { x = f; }
function f(bytes calldata b) internal pure returns (byte) {
function f(bytes calldata b) internal pure returns (bytes1) {
return b[2];
}
function h(bytes calldata b) external returns (byte) {
function h(bytes calldata b) external returns (bytes1) {
return x(b);
}
function g() external returns (byte) {
function g() external returns (bytes1) {
bytes memory a = new bytes(34);
a[2] = byte(uint8(7));
a[2] = bytes1(uint8(7));
return this.h(a);
}
}

View File

@ -1,16 +1,16 @@
library L {
function f(uint, bytes calldata _x, uint) internal returns (byte) {
function f(uint, bytes calldata _x, uint) internal returns (bytes1) {
return _x[2];
}
}
contract C {
function f(bytes calldata a)
external
returns (byte)
returns (bytes1)
{
return L.f(3, a, 9);
}
function g() public returns (byte) {
function g() public returns (bytes1) {
bytes memory x = new bytes(4);
x[2] = 0x08;
return this.f(x);

View File

@ -1,11 +1,11 @@
contract C {
function f(bytes memory _a, bytes calldata _b, bytes memory _c)
public
returns (uint, byte, byte, byte)
returns (uint, bytes1, bytes1, bytes1)
{
return (_a.length + _b.length + _c.length, _a[1], _b[1], _c[1]);
}
function g() public returns (uint, byte, byte, byte) {
function g() public returns (uint, bytes1, bytes1, bytes1) {
bytes memory x = new bytes(3);
bytes memory y = new bytes(4);
bytes memory z = new bytes(7);

View File

@ -3,7 +3,7 @@
contract C {
address constant e = 0x1212121212121212121212121000002134593163;
function f() public returns (byte z) {
function f() public returns (bytes1 z) {
assembly { z := e }
}
}

View File

@ -5,7 +5,7 @@ contract Base {
m_x = x;
m_s = s;
}
function part(uint i) public returns (byte) {
function part(uint i) public returns (bytes1) {
return m_s[i];
}
}
@ -16,7 +16,7 @@ contract Main is Base {
}
}
contract Creator {
function f(uint x, bytes memory s) public returns (uint r, byte ch) {
function f(uint x, bytes memory s) public returns (uint r, bytes1 ch) {
Main c = new Main(s, x);
r = c.m_x();
ch = c.part(x);

View File

@ -1,6 +1,6 @@
contract C {
function f(bytes calldata b) public returns (bool correct) {
byte a = b[3];
bytes1 a = b[3];
uint r;
assembly {
r := a

View File

@ -9,7 +9,7 @@ library D {
contract C {
using D for bytes;
function f(bytes calldata _x) public pure returns (byte, byte) {
function f(bytes calldata _x) public pure returns (bytes1, bytes1) {
return (_x.f()[0], _x.g()[0]);
}
}

View File

@ -9,7 +9,7 @@ library D {
contract C {
using D for bytes;
function f(bytes calldata _x) public pure returns (byte, byte) {
function f(bytes calldata _x) public pure returns (bytes1, bytes1) {
return (_x.f()[0], _x.g()[0]);
}
}

View File

@ -1,15 +1,15 @@
library D {
function f(bytes calldata _x) internal pure returns (byte) {
function f(bytes calldata _x) internal pure returns (bytes1) {
return _x[0];
}
function g(bytes memory _x) internal pure returns (byte) {
function g(bytes memory _x) internal pure returns (bytes1) {
return _x[0];
}
}
contract C {
using D for bytes;
function f(bytes calldata _x) public pure returns (byte, byte) {
function f(bytes calldata _x) public pure returns (bytes1, bytes1) {
return (_x.f(), _x.g());
}
}

View File

@ -1,15 +1,15 @@
library D {
function f(bytes calldata _x) public pure returns (byte) {
function f(bytes calldata _x) public pure returns (bytes1) {
return _x[0];
}
function g(bytes memory _x) public pure returns (byte) {
function g(bytes memory _x) public pure returns (bytes1) {
return _x[0];
}
}
contract C {
using D for bytes;
function f(bytes calldata _x) public pure returns (byte, byte) {
function f(bytes calldata _x) public pure returns (bytes1, bytes1) {
return (_x.f(), _x.g());
}
}

View File

@ -1,8 +1,8 @@
pragma abicoder v2;
pragma abicoder v2;
contract C
{
function f() public pure returns (uint, byte, byte) {
function f() public pure returns (uint, bytes1, bytes1) {
bytes memory encoded = abi.encodePacked("\\\\");
return (encoded.length, encoded[0], encoded[1]);
}

View File

@ -14,7 +14,7 @@ contract C {
function f(S1 calldata s1)
external
pure
returns (uint256 a, uint64 b0, byte b1, uint256 c)
returns (uint256 a, uint64 b0, bytes1 b1, uint256 c)
{
a = s1.a;
b0 = s1.s.a;

View File

@ -1,4 +1,4 @@
pragma abicoder v2;
pragma abicoder v2;
contract C {
struct S {
@ -7,7 +7,7 @@ contract C {
bytes2 c;
}
function f(S calldata s) external pure returns (uint256, uint256, byte) {
function f(S calldata s) external pure returns (uint256, uint256, bytes1) {
S memory m = s;
return (m.a, m.b, m.c[1]);
}

View File

@ -1,4 +1,4 @@
pragma abicoder v2;
pragma abicoder v2;
contract C {
struct S {
@ -10,7 +10,7 @@ contract C {
uint[153] r;
S s;
function f(uint32 a, S calldata c, uint256 b) external returns (uint256, uint256, byte) {
function f(uint32 a, S calldata c, uint256 b) external returns (uint256, uint256, bytes1) {
s = c;
return (s.a, s.b, s.c[1]);
}

View File

@ -10,7 +10,7 @@ contract C {
function f(S calldata c)
external
pure
returns (uint256, byte, byte, uint256)
returns (uint256, bytes1, bytes1, uint256)
{
S memory m = c;
return (m.a, m.b[0], m.b[1], m.c);

View File

@ -16,7 +16,7 @@ contract c {
delete data1;
return true;
}
function test(uint256 i) public returns (byte) {
function test(uint256 i) public returns (bytes1) {
return data1.data[i];
}
}

View File

@ -4,7 +4,7 @@ contract C {
assembly {
sstore(b.slot, or("deadbeef", 0x08))
}
byte s = b[3];
bytes1 s = b[3];
uint r;
assembly {
r := s

View File

@ -6,7 +6,7 @@ contract C {
mstore(0, b.slot)
sstore(keccak256(0, 0x20), "deadbeefdeadbeefdeadbeefdeadbeef")
}
byte s = b[31];
bytes1 s = b[31];
uint r;
assembly {
r := s

View File

@ -1,10 +1,10 @@
contract C {
uint16 x;
byte y;
bytes1 y;
uint16 z;
function f(uint8 a) public returns (uint _x) {
x = a;
y = byte(uint8(x) + 1);
y = bytes1(uint8(x) + 1);
z = uint8(y) + 1;
x = z + 1;
_x = x;

View File

@ -32,9 +32,6 @@ contract C {
function r_b1() public pure returns (bytes1) {
return ~bytes1(hex"55");
}
function r_b() public pure returns (byte) {
return ~byte(hex"55");
}
function a_b32() public pure returns (bytes32) {
bytes32 r = ~bytes32(hex"ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00");
@ -56,14 +53,10 @@ contract C {
bytes4 r = ~bytes4(hex"ff00ff00");
return r;
}
function a_b1() public pure returns (byte) {
function a_b1() public pure returns (bytes1) {
bytes1 r = ~bytes1(hex"55");
return r;
}
function a_b() public pure returns (byte) {
byte r = ~byte(hex"55");
return r;
}
}
// ====
// compileViaYul: also
@ -77,11 +70,9 @@ contract C {
// r_b8() -> 0xff00ff00ff00ff000000000000000000000000000000000000000000000000
// r_b4() -> 0xff00ff00000000000000000000000000000000000000000000000000000000
// r_b1() -> 0xaa00000000000000000000000000000000000000000000000000000000000000
// r_b() -> 0xaa00000000000000000000000000000000000000000000000000000000000000
// a_b32() -> 0xff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff
// a_b25() -> 0xff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff0000000000000000
// a_b16() -> 0xff00ff00ff00ff00ff00ff00ff00ff00000000000000000000000000000000
// a_b8() -> 0xff00ff00ff00ff000000000000000000000000000000000000000000000000
// a_b4() -> 0xff00ff00000000000000000000000000000000000000000000000000000000
// a_b1() -> 0xaa00000000000000000000000000000000000000000000000000000000000000
// a_b() -> 0xaa00000000000000000000000000000000000000000000000000000000000000

View File

@ -1,11 +1,11 @@
pragma experimental SMTChecker;
contract C {
byte public x;
bytes1 public x;
bytes3 public y;
function f() public view {
byte a = this.x();
bytes1 a = this.x();
bytes3 b = this.y();
assert(a == x); // should hold
assert(a == 'a'); // should fail
@ -14,5 +14,5 @@ contract C {
}
}
// ----
// Warning 6328: (188-204): CHC: Assertion violation happens here.\nCounterexample:\nx = 0, y = 0\n\n\n\nTransaction trace:\nconstructor()\nState: x = 0, y = 0\nf()
// Warning 6328: (256-274): CHC: Assertion violation happens here.\nCounterexample:\nx = 0, y = 0\n\n\n\nTransaction trace:\nconstructor()\nState: x = 0, y = 0\nf()
// Warning 6328: (192-208): CHC: Assertion violation happens here.\nCounterexample:\nx = 0, y = 0\n\n\n\nTransaction trace:\nconstructor()\nState: x = 0, y = 0\nf()
// Warning 6328: (260-278): CHC: Assertion violation happens here.\nCounterexample:\nx = 0, y = 0\n\n\n\nTransaction trace:\nconstructor()\nState: x = 0, y = 0\nf()

View File

@ -1,11 +1,11 @@
pragma experimental SMTChecker;
contract C {
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
assert(bytes1("") & ("") == bytes1(0)); // should hold
assert(bytes1(0xAA) & bytes1(0x55) == bytes1(0)); // should hold
assert(bytes1(0xFF) & bytes1(0xAA) == bytes1(0xAA)); // should hold
assert(bytes1(0xFF) & bytes1(0xAA) == bytes1(0)); // should fail
}
}
// ----
// Warning 6328: (253-295): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
// Warning 6328: (269-317): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()

View File

@ -1,11 +1,11 @@
pragma experimental SMTChecker;
contract C {
function f() public pure returns (byte) {
byte b = (byte(0x0F) | (byte(0xF0)));
assert(b == byte(0xFF)); // should hold
assert(b == byte(0x00)); // should fail
function f() public pure returns (bytes1) {
bytes1 b = (bytes1(0x0F) | (bytes1(0xF0)));
assert(b == bytes1(0xFF)); // should hold
assert(b == bytes1(0x00)); // should fail
return b;
}
}
// ----
// Warning 6328: (172-195): CHC: Assertion violation happens here.\nCounterexample:\n\n\n = 0\n\nTransaction trace:\nconstructor()\nf()
// Warning 6328: (182-207): CHC: Assertion violation happens here.\nCounterexample:\n\n\n = 0\n\nTransaction trace:\nconstructor()\nf()

View File

@ -1,11 +1,11 @@
pragma experimental SMTChecker;
contract Simp {
function f3() public pure returns (byte) {
function f3() public pure returns (bytes1) {
bytes memory y = "def";
assert(y[0] ^ "e" != byte(0)); // should hold
assert(y[1] ^ "e" != byte(0)); // should fail
assert(y[0] ^ "e" != bytes1(0)); // should hold
assert(y[1] ^ "e" != bytes1(0)); // should fail
return y[0];
}
}
// ----
// Warning 6328: (168-197): CHC: Assertion violation happens here.\nCounterexample:\n\n\n = 0\n\nTransaction trace:\nconstructor()\nf3()
// Warning 6328: (172-203): CHC: Assertion violation happens here.\nCounterexample:\n\n\n = 0\n\nTransaction trace:\nconstructor()\nf3()

View File

@ -1,8 +1,8 @@
pragma experimental SMTChecker;
contract C {
function f() public pure returns (byte) {
byte a = 0xff;
byte b = 0xf0;
function f() public pure returns (bytes1) {
bytes1 a = 0xff;
bytes1 b = 0xf0;
a &= b;
assert(a == b);
@ -11,5 +11,5 @@ contract C {
}
}
// ----
// Warning 6321: (83-87): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
// Warning 6328: (203-217): CHC: Assertion violation happens here.\nCounterexample:\n\n\n = 0\n\nTransaction trace:\nconstructor()\nf()
// Warning 6321: (83-89): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
// Warning 6328: (209-223): CHC: Assertion violation happens here.\nCounterexample:\n\n\n = 0\n\nTransaction trace:\nconstructor()\nf()

View File

@ -1,8 +1,8 @@
pragma experimental SMTChecker;
contract C {
function f() public pure returns (byte) {
byte a = 0xff;
byte b = 0xf0;
function f() public pure returns (bytes1) {
bytes1 a = 0xff;
bytes1 b = 0xf0;
b |= a;
assert(a == b);
@ -11,5 +11,5 @@ contract C {
}
}
// ----
// Warning 6321: (83-87): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
// Warning 6328: (203-217): CHC: Assertion violation happens here.\nCounterexample:\n\n\n = 0\n\nTransaction trace:\nconstructor()\nf()
// Warning 6321: (83-89): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
// Warning 6328: (209-223): CHC: Assertion violation happens here.\nCounterexample:\n\n\n = 0\n\nTransaction trace:\nconstructor()\nf()

View File

@ -10,7 +10,7 @@ contract C {
assert(y[0] == "d"); // fails
y[0] ^= "f";
assert(y[0] == (byte("d") | byte("e")) ^ byte("f"));
assert(y[0] == (bytes1("d") | bytes1("e")) ^ bytes1("f"));
}
}
// ----

View File

@ -1,8 +1,8 @@
pragma experimental SMTChecker;
contract C {
function f() public pure returns (byte) {
byte a = 0xff;
byte b = 0xf0;
function f() public pure returns (bytes1) {
bytes1 a = 0xff;
bytes1 b = 0xf0;
a ^= ~b;
assert(a == b);
@ -11,5 +11,5 @@ contract C {
}
}
// ----
// Warning 6321: (83-87): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
// Warning 6328: (204-221): CHC: Assertion violation happens here.\nCounterexample:\n\n\n = 0\n\nTransaction trace:\nconstructor()\nf()
// Warning 6321: (83-89): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
// Warning 6328: (210-227): CHC: Assertion violation happens here.\nCounterexample:\n\n\n = 0\n\nTransaction trace:\nconstructor()\nf()

View File

@ -1,16 +1,16 @@
pragma experimental SMTChecker;
contract C {
mapping (byte => uint) map;
mapping (bytes1 => uint) map;
function f() public {
map[""] = 2;
uint x = map[""];
g("");
byte b = "";
bytes1 b = "";
assert(x == map[b]);
assert(x == map["x"]);
}
function g(byte b) internal pure {}
function g(bytes1 b) internal pure {}
}
// ----
// Warning 6328: (182-203): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
// Warning 6328: (186-207): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()

View File

@ -4,9 +4,9 @@ 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
assert(b[0] == bytes1(uint8(255))); // should hold
assert(b[1] == bytes1(uint8(100))); // should fail
}
}
// ----
// Warning 6328: (204-236): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
// Warning 6328: (206-240): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()

View File

@ -3,8 +3,8 @@ pragma experimental SMTChecker;
contract C {
function f() public pure {
bytes32 x = 0x00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff;
byte z = 0x00;
byte o = 0xff;
bytes1 z = 0x00;
bytes1 o = 0xff;
assert(x[0] == z);
assert(x[31] == o);
assert(x[0] == x[22]);
@ -12,4 +12,4 @@ contract C {
}
}
// ----
// Warning 6328: (260-281): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
// Warning 6328: (264-285): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()

View File

@ -3,7 +3,7 @@ pragma experimental SMTChecker;
contract C {
function f() public pure {
bytes4 x = 0x01020304;
byte b = 0x02;
bytes1 b = 0x02;
assert(x[0] == b); // fails
assert(x[1] == b);
assert(x[2] == b); // fails
@ -11,6 +11,6 @@ contract C {
}
}
// ----
// Warning 6328: (118-135): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
// Warning 6328: (169-186): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
// Warning 6328: (199-216): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
// Warning 6328: (120-137): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
// Warning 6328: (171-188): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
// Warning 6328: (201-218): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()

View File

@ -3,7 +3,7 @@ pragma experimental SMTChecker;
contract C {
function f() public pure {
bytes4 x = 0x01020304;
byte b = x[3];
bytes1 b = x[3];
assert(b == b[0]);
assert(b == b[0][0]);
assert(b == b[0][0][0][0][0][0][0][0][0][0][0]);

View File

@ -1,7 +1,7 @@
pragma experimental SMTChecker;
contract test {
struct s { uint a; uint b;}
function f() pure public returns (byte) {
struct s { uint a; uint b;}
function f() pure public returns (bytes1) {
s;
s(1,2);
s[7];
@ -10,13 +10,13 @@ contract test {
}
}
// ----
// Warning 6321: (115-119): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
// Warning 6133: (125-126): Statement has no effect.
// Warning 6133: (130-136): Statement has no effect.
// Warning 6133: (140-144): Statement has no effect.
// Warning 6133: (148-152): Statement has no effect.
// Warning 6133: (156-163): Statement has no effect.
// Warning 8364: (140-144): Assertion checker does not yet implement type type(struct test.s memory[7] memory)
// Warning 8364: (156-163): Assertion checker does not yet implement type type(uint256[7] memory)
// Warning 8364: (140-144): Assertion checker does not yet implement type type(struct test.s memory[7] memory)
// Warning 8364: (156-163): Assertion checker does not yet implement type type(uint256[7] memory)
// Warning 6321: (118-124): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
// Warning 6133: (130-131): Statement has no effect.
// Warning 6133: (135-141): Statement has no effect.
// Warning 6133: (145-149): Statement has no effect.
// Warning 6133: (153-157): Statement has no effect.
// Warning 6133: (161-168): Statement has no effect.
// Warning 8364: (145-149): Assertion checker does not yet implement type type(struct test.s memory[7] memory)
// Warning 8364: (161-168): Assertion checker does not yet implement type type(uint256[7] memory)
// Warning 8364: (145-149): Assertion checker does not yet implement type type(struct test.s memory[7] memory)
// Warning 8364: (161-168): Assertion checker does not yet implement type type(uint256[7] memory)

View File

@ -1,9 +1,9 @@
contract C {
byte[32] data1;
bytes1[32] data1;
bytes2[10] data2;
function f() external {
data1 = data2;
}
}
// ----
// TypeError 7407: (99-104): Type bytes2[10] storage ref is not implicitly convertible to expected type bytes1[32] storage ref.
// TypeError 7407: (101-106): Type bytes2[10] storage ref is not implicitly convertible to expected type bytes1[32] storage ref.

View File

@ -1,8 +1,8 @@
// Used to cause ICE
contract C {
function f() public {
abi.decode("", (byte[999999999]));
abi.decode("", (bytes1[999999999]));
}
}
// ----
// TypeError 6118: (75-90): Type too large for memory.
// TypeError 6118: (75-92): Type too large for memory.

View File

@ -1,7 +1,7 @@
contract C {
function a() public pure returns(int[0][500] memory) {}
function b() public pure returns(uint[0][500] memory) {}
function c() public pure returns(byte[0][500] memory) {}
function c() public pure returns(bytes1[0][500] memory) {}
function d() public pure returns(bytes32[0][500] memory) {}
function e() public pure returns(bytes[0][500] memory) {}
function e() public pure returns(string[0][500] memory) {}
@ -9,7 +9,7 @@ contract C {
// ----
// TypeError 1406: (52-53): Array with zero length specified.
// TypeError 1406: (111-112): Array with zero length specified.
// TypeError 1406: (170-171): Array with zero length specified.
// TypeError 1406: (232-233): Array with zero length specified.
// TypeError 1406: (292-293): Array with zero length specified.
// TypeError 1406: (353-354): Array with zero length specified.
// TypeError 1406: (172-173): Array with zero length specified.
// TypeError 1406: (234-235): Array with zero length specified.
// TypeError 1406: (294-295): Array with zero length specified.
// TypeError 1406: (355-356): Array with zero length specified.

View File

@ -1,7 +1,7 @@
contract C {
int[0] a;
uint[0] b;
byte[0] c;
bytes1[0] c;
bytes32[0] d;
bytes[0] e;
string[0] f;
@ -9,7 +9,7 @@ contract C {
// ----
// TypeError 1406: (19-20): Array with zero length specified.
// TypeError 1406: (32-33): Array with zero length specified.
// TypeError 1406: (45-46): Array with zero length specified.
// TypeError 1406: (61-62): Array with zero length specified.
// TypeError 1406: (75-76): Array with zero length specified.
// TypeError 1406: (90-91): Array with zero length specified.
// TypeError 1406: (47-48): Array with zero length specified.
// TypeError 1406: (63-64): Array with zero length specified.
// TypeError 1406: (77-78): Array with zero length specified.
// TypeError 1406: (92-93): Array with zero length specified.

View File

@ -1,10 +1,10 @@
contract test {
struct s { uint a; uint b;}
function f() pure public returns (byte) {
struct s { uint a; uint b;}
function f() pure public returns (bytes1) {
s[75555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555];
s[7];
}
}
// ----
// TypeError 7407: (101-241): Type int_const 7555...(132 digits omitted)...5555 is not implicitly convertible to expected type uint256. Literal is too large to fit in uint256.
// TypeError 7407: (106-246): Type int_const 7555...(132 digits omitted)...5555 is not implicitly convertible to expected type uint256. Literal is too large to fit in uint256.

View File

@ -1,7 +1,7 @@
contract c {
bytes arr;
function f() public { byte a = arr[0];}
function f() public { bytes1 a = arr[0];}
}
// ----
// Warning 2072: (54-60): Unused local variable.
// Warning 2018: (32-71): Function state mutability can be restricted to view
// Warning 2072: (54-62): Unused local variable.
// Warning 2018: (32-73): Function state mutability can be restricted to view

View File

@ -36,15 +36,15 @@ contract C {
// real is not there yet.
// array
byte[2] memory a;
byte[2] memory b;
byte[2] memory k = true ? a : b;
k[0] = byte(0); //Avoid unused var warning
bytes1[2] memory a;
bytes1[2] memory b;
bytes1[2] memory k = true ? a : b;
k[0] = bytes1(0); //Avoid unused var warning
bytes memory e;
bytes memory f;
bytes memory l = true ? e : f;
l[0] = byte(0); // Avoid unused var warning
l[0] = bytes1(0); // Avoid unused var warning
// fixed bytes
bytes2 c;
@ -84,6 +84,6 @@ contract C {
}
}
// ----
// Warning 2519: (1005-1019): This declaration shadows an existing declaration.
// Warning 2519: (1013-1027): This declaration shadows an existing declaration.
// Warning 2018: (257-642): Function state mutability can be restricted to pure
// Warning 2018: (647-1227): Function state mutability can be restricted to pure
// Warning 2018: (647-1237): Function state mutability can be restricted to pure

View File

@ -1,5 +1,5 @@
contract C {
function o(byte) public pure {}
function o(bytes1) public pure {}
function f() public {
o(true ? 99**99 : 99);
o(true ? 99 : 99**99);
@ -8,9 +8,9 @@ contract C {
}
}
// ----
// TypeError 9717: (92-98): Invalid mobile type in true expression.
// TypeError 9553: (85-103): Invalid type for argument in function call. Invalid implicit conversion from uint8 to bytes1 requested.
// TypeError 3703: (128-134): Invalid mobile type in false expression.
// TypeError 9553: (116-134): Invalid type for argument in function call. Invalid implicit conversion from uint8 to bytes1 requested.
// TypeError 9717: (155-161): Invalid mobile type in true expression.
// TypeError 3703: (164-170): Invalid mobile type in false expression.
// TypeError 9717: (94-100): Invalid mobile type in true expression.
// TypeError 9553: (87-105): Invalid type for argument in function call. Invalid implicit conversion from uint8 to bytes1 requested.
// TypeError 3703: (130-136): Invalid mobile type in false expression.
// TypeError 9553: (118-136): Invalid type for argument in function call. Invalid implicit conversion from uint8 to bytes1 requested.
// TypeError 9717: (157-163): Invalid mobile type in true expression.
// TypeError 3703: (166-172): Invalid mobile type in false expression.

View File

@ -1,6 +1,6 @@
contract test {
struct s { uint a; uint b;}
function f() pure public returns (byte) {
function f() pure public returns (bytes1) {
s;
s(1,2);
s[7];
@ -9,9 +9,9 @@ contract test {
}
}
// ----
// Warning 6321: (83-87): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
// Warning 6133: (93-94): Statement has no effect.
// Warning 6133: (98-104): Statement has no effect.
// Warning 6133: (108-112): Statement has no effect.
// Warning 6133: (116-120): Statement has no effect.
// Warning 6133: (124-131): Statement has no effect.
// Warning 6321: (83-89): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
// Warning 6133: (95-96): Statement has no effect.
// Warning 6133: (100-106): Statement has no effect.
// Warning 6133: (110-114): Statement has no effect.
// Warning 6133: (118-122): Statement has no effect.
// Warning 6133: (126-133): Statement has no effect.

View File

@ -5,7 +5,7 @@ contract C {
int256 payable d;
uint payable e;
uint256 payable f;
byte payable g;
bytes1 payable g;
bytes payable h;
bytes32 payable i;
fixed payable j;
@ -20,10 +20,10 @@ contract C {
// ParserError 9106: (85-92): State mutability can only be specified for address types.
// ParserError 9106: (105-112): State mutability can only be specified for address types.
// ParserError 9106: (128-135): State mutability can only be specified for address types.
// ParserError 9106: (148-155): State mutability can only be specified for address types.
// ParserError 9106: (169-176): State mutability can only be specified for address types.
// ParserError 9106: (192-199): State mutability can only be specified for address types.
// ParserError 9106: (213-220): State mutability can only be specified for address types.
// ParserError 9106: (239-246): State mutability can only be specified for address types.
// ParserError 9106: (261-268): State mutability can only be specified for address types.
// ParserError 9106: (288-295): State mutability can only be specified for address types.
// ParserError 9106: (150-157): State mutability can only be specified for address types.
// ParserError 9106: (171-178): State mutability can only be specified for address types.
// ParserError 9106: (194-201): State mutability can only be specified for address types.
// ParserError 9106: (215-222): State mutability can only be specified for address types.
// ParserError 9106: (241-248): State mutability can only be specified for address types.
// ParserError 9106: (263-270): State mutability can only be specified for address types.
// ParserError 9106: (290-297): State mutability can only be specified for address types.

View File

@ -5,7 +5,7 @@ contract C {
function d(int256 payable) public pure {}
function e(uint payable) public pure {}
function f(uint256 payable) public pure {}
function g(byte payable) public pure {}
function g(bytes1 payable) public pure {}
function h(bytes payable) public pure {}
function i(bytes32 payable) public pure {}
function j(fixed payable) public pure {}
@ -20,10 +20,10 @@ contract C {
// ParserError 9106: (168-175): State mutability can only be specified for address types.
// ParserError 9106: (212-219): State mutability can only be specified for address types.
// ParserError 9106: (259-266): State mutability can only be specified for address types.
// ParserError 9106: (303-310): State mutability can only be specified for address types.
// ParserError 9106: (348-355): State mutability can only be specified for address types.
// ParserError 9106: (395-402): State mutability can only be specified for address types.
// ParserError 9106: (440-447): State mutability can only be specified for address types.
// ParserError 9106: (490-497): State mutability can only be specified for address types.
// ParserError 9106: (536-543): State mutability can only be specified for address types.
// ParserError 9106: (587-594): State mutability can only be specified for address types.
// ParserError 9106: (305-312): State mutability can only be specified for address types.
// ParserError 9106: (350-357): State mutability can only be specified for address types.
// ParserError 9106: (397-404): State mutability can only be specified for address types.
// ParserError 9106: (442-449): State mutability can only be specified for address types.
// ParserError 9106: (492-499): State mutability can only be specified for address types.
// ParserError 9106: (538-545): State mutability can only be specified for address types.
// ParserError 9106: (589-596): State mutability can only be specified for address types.

View File

@ -6,7 +6,7 @@ contract C {
int256 payable d;
uint payable e;
uint256 payable f;
byte payable g;
bytes1 payable g;
bytes payable h;
bytes32 payable i;
fixed payable j;
@ -22,10 +22,10 @@ contract C {
// ParserError 9106: (132-139): State mutability can only be specified for address types.
// ParserError 9106: (156-163): State mutability can only be specified for address types.
// ParserError 9106: (183-190): State mutability can only be specified for address types.
// ParserError 9106: (207-214): State mutability can only be specified for address types.
// ParserError 9106: (232-239): State mutability can only be specified for address types.
// ParserError 9106: (259-266): State mutability can only be specified for address types.
// ParserError 9106: (284-291): State mutability can only be specified for address types.
// ParserError 9106: (314-321): State mutability can only be specified for address types.
// ParserError 9106: (340-347): State mutability can only be specified for address types.
// ParserError 9106: (371-378): State mutability can only be specified for address types.
// ParserError 9106: (209-216): State mutability can only be specified for address types.
// ParserError 9106: (234-241): State mutability can only be specified for address types.
// ParserError 9106: (261-268): State mutability can only be specified for address types.
// ParserError 9106: (286-293): State mutability can only be specified for address types.
// ParserError 9106: (316-323): State mutability can only be specified for address types.
// ParserError 9106: (342-349): State mutability can only be specified for address types.
// ParserError 9106: (373-380): State mutability can only be specified for address types.

View File

@ -5,7 +5,7 @@ contract C {
function d() public pure returns (int256 payable) {}
function e() public pure returns (uint payable) {}
function f() public pure returns (uint256 payable) {}
function g() public pure returns (byte payable) {}
function g() public pure returns (bytes1 payable) {}
function h() public pure returns (bytes payable) {}
function i() public pure returns (bytes32 payable) {}
function j() public pure returns (fixed payable) {}
@ -20,10 +20,10 @@ contract C {
// ParserError 9106: (224-231): State mutability can only be specified for address types.
// ParserError 9106: (279-286): State mutability can only be specified for address types.
// ParserError 9106: (337-344): State mutability can only be specified for address types.
// ParserError 9106: (392-399): State mutability can only be specified for address types.
// ParserError 9106: (448-455): State mutability can only be specified for address types.
// ParserError 9106: (506-513): State mutability can only be specified for address types.
// ParserError 9106: (562-569): State mutability can only be specified for address types.
// ParserError 9106: (623-630): State mutability can only be specified for address types.
// ParserError 9106: (680-687): State mutability can only be specified for address types.
// ParserError 9106: (742-749): State mutability can only be specified for address types.
// ParserError 9106: (394-401): State mutability can only be specified for address types.
// ParserError 9106: (450-457): State mutability can only be specified for address types.
// ParserError 9106: (508-515): State mutability can only be specified for address types.
// ParserError 9106: (564-571): State mutability can only be specified for address types.
// ParserError 9106: (625-632): State mutability can only be specified for address types.
// ParserError 9106: (682-689): State mutability can only be specified for address types.
// ParserError 9106: (744-751): State mutability can only be specified for address types.

View File

@ -0,0 +1,5 @@
contract C {
byte public a;
}
// ----
// ParserError 9182: (17-21): Function, variable, struct or modifier declaration expected.

View File

@ -1,6 +1,5 @@
contract C {
byte b = byte(0x01);
bytes1 b1 = b;
bytes1 b1 = bytes1(0x01);
bytes2 b2 = b1;
bytes3 b3 = b2;
bytes4 b4 = b3;