mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #10598 from ethereum/disable-byte
[BREAKING] Disable the type `byte`
This commit is contained in:
commit
5f59a949d7
@ -15,6 +15,7 @@ Breaking Changes:
|
|||||||
* Standard JSON: Remove the ``legacyAST`` option.
|
* Standard JSON: Remove the ``legacyAST`` option.
|
||||||
* Type Checker: Function call options can only be given once.
|
* Type Checker: Function call options can only be given once.
|
||||||
* Type System: Declarations with the name ``this``, ``super`` and ``_`` are disallowed, with the exception of public functions and events.
|
* Type System: Declarations with the name ``this``, ``super`` and ``_`` are disallowed, with the exception of public functions and events.
|
||||||
|
* Type System: Disallow the ``byte`` type. It was an alias to ``bytes1``.
|
||||||
* Type System: Disallow ``msg.data`` in ``receive()`` function.
|
* Type System: Disallow ``msg.data`` in ``receive()`` function.
|
||||||
* Type System: Disallow ``type(super)``.
|
* Type System: Disallow ``type(super)``.
|
||||||
* Type System: Disallow enums with more than 256 members.
|
* Type System: Disallow enums with more than 256 members.
|
||||||
|
@ -50,6 +50,8 @@ the compiler notifying you about it.
|
|||||||
in all branches of the evaluation tree. Now, if constant variables are used as intermediate expressions,
|
in all branches of the evaluation tree. Now, if constant variables are used as intermediate expressions,
|
||||||
their values will be properly rounded in the same way as when they are used in run-time expressions.
|
their values will be properly rounded in the same way as when they are used in run-time expressions.
|
||||||
|
|
||||||
|
* The type ``byte`` has been removed. It was an alias of ``bytes1``.
|
||||||
|
|
||||||
New Restrictions
|
New Restrictions
|
||||||
================
|
================
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ Local Solidity variables are available for assignments, for example:
|
|||||||
|
|
||||||
.. warning::
|
.. warning::
|
||||||
If you access variables of a type that spans less than 256 bits
|
If you access variables of a type that spans less than 256 bits
|
||||||
(for example ``uint64``, ``address``, ``bytes16`` or ``byte``),
|
(for example ``uint64``, ``address``, or ``bytes16``),
|
||||||
you cannot make any assumptions about bits not part of the
|
you cannot make any assumptions about bits not part of the
|
||||||
encoding of the type. Especially, do not assume them to be zero.
|
encoding of the type. Especially, do not assume them to be zero.
|
||||||
To be safe, always clear the data properly before you use it
|
To be safe, always clear the data properly before you use it
|
||||||
|
@ -261,7 +261,7 @@ which only need to be created if there is a dispute.
|
|||||||
// can be pre-computed. It is just there for illustration.
|
// can be pre-computed. It is just there for illustration.
|
||||||
// You actually only need ``new D{salt: salt}(arg)``.
|
// You actually only need ``new D{salt: salt}(arg)``.
|
||||||
address predictedAddress = address(uint160(uint(keccak256(abi.encodePacked(
|
address predictedAddress = address(uint160(uint(keccak256(abi.encodePacked(
|
||||||
byte(0xff),
|
bytes1(0xff),
|
||||||
address(this),
|
address(this),
|
||||||
salt,
|
salt,
|
||||||
keccak256(abi.encodePacked(
|
keccak256(abi.encodePacked(
|
||||||
|
@ -4,7 +4,7 @@ lexer grammar SolidityLexer;
|
|||||||
* Keywords reserved for future use in Solidity.
|
* Keywords reserved for future use in Solidity.
|
||||||
*/
|
*/
|
||||||
ReservedKeywords:
|
ReservedKeywords:
|
||||||
'after' | 'alias' | 'apply' | 'auto' | 'case' | 'copyof' | 'default' | 'define' | 'final'
|
'after' | 'alias' | 'apply' | 'auto' | 'byte' | 'case' | 'copyof' | 'default' | 'define' | 'final'
|
||||||
| 'implements' | 'in' | 'inline' | 'let' | 'macro' | 'match' | 'mutable' | 'null' | 'of'
|
| 'implements' | 'in' | 'inline' | 'let' | 'macro' | 'match' | 'mutable' | 'null' | 'of'
|
||||||
| 'partial' | 'promise' | 'reference' | 'relocatable' | 'sealed' | 'sizeof' | 'static'
|
| 'partial' | 'promise' | 'reference' | 'relocatable' | 'sealed' | 'sizeof' | 'static'
|
||||||
| 'supports' | 'switch' | 'typedef' | 'typeof' | 'var';
|
| 'supports' | 'switch' | 'typedef' | 'typeof' | 'var';
|
||||||
@ -37,10 +37,9 @@ Fixed: 'fixed' | ('fixed' [1-9][0-9]* 'x' [1-9][0-9]*);
|
|||||||
From: 'from';
|
From: 'from';
|
||||||
/**
|
/**
|
||||||
* Bytes types of fixed length.
|
* Bytes types of fixed length.
|
||||||
* byte is an alias of bytes1.
|
|
||||||
*/
|
*/
|
||||||
FixedBytes:
|
FixedBytes:
|
||||||
'byte' | 'bytes1' | 'bytes2' | 'bytes3' | 'bytes4' | 'bytes5' | 'bytes6' | 'bytes7' | 'bytes8' |
|
'bytes1' | 'bytes2' | 'bytes3' | 'bytes4' | 'bytes5' | 'bytes6' | 'bytes7' | 'bytes8' |
|
||||||
'bytes9' | 'bytes10' | 'bytes11' | 'bytes12' | 'bytes13' | 'bytes14' | 'bytes15' | 'bytes16' |
|
'bytes9' | 'bytes10' | 'bytes11' | 'bytes12' | 'bytes13' | 'bytes14' | 'bytes15' | 'bytes16' |
|
||||||
'bytes17' | 'bytes18' | 'bytes19' | 'bytes20' | 'bytes21' | 'bytes22' | 'bytes23' | 'bytes24' |
|
'bytes17' | 'bytes18' | 'bytes19' | 'bytes20' | 'bytes21' | 'bytes22' | 'bytes23' | 'bytes24' |
|
||||||
'bytes25' | 'bytes26' | 'bytes27' | 'bytes28' | 'bytes29' | 'bytes30' | 'bytes31' | 'bytes32';
|
'bytes25' | 'bytes26' | 'bytes27' | 'bytes28' | 'bytes29' | 'bytes30' | 'bytes31' | 'bytes32';
|
||||||
|
@ -391,7 +391,7 @@ Array Members
|
|||||||
// Create a dynamic byte array:
|
// Create a dynamic byte array:
|
||||||
bytes memory b = new bytes(200);
|
bytes memory b = new bytes(200);
|
||||||
for (uint i = 0; i < b.length; i++)
|
for (uint i = 0; i < b.length; i++)
|
||||||
b[i] = byte(uint8(i));
|
b[i] = bytes1(uint8(i));
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -369,7 +369,6 @@ Fixed-size byte arrays
|
|||||||
|
|
||||||
The value types ``bytes1``, ``bytes2``, ``bytes3``, ..., ``bytes32``
|
The value types ``bytes1``, ``bytes2``, ``bytes3``, ..., ``bytes32``
|
||||||
hold a sequence of bytes from one to up to 32.
|
hold a sequence of bytes from one to up to 32.
|
||||||
``byte`` is an alias for ``bytes1``.
|
|
||||||
|
|
||||||
Operators:
|
Operators:
|
||||||
|
|
||||||
@ -391,6 +390,9 @@ Members:
|
|||||||
31 bytes of space for each element (except in storage). It is better to use the ``bytes``
|
31 bytes of space for each element (except in storage). It is better to use the ``bytes``
|
||||||
type instead.
|
type instead.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
Prior to version 0.8.0, ``byte`` used to be an alias for ``bytes1``.
|
||||||
|
|
||||||
Dynamically-sized byte array
|
Dynamically-sized byte array
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
|
@ -212,7 +212,6 @@ namespace solidity::langutil
|
|||||||
K(Int, "int", 0) \
|
K(Int, "int", 0) \
|
||||||
K(UInt, "uint", 0) \
|
K(UInt, "uint", 0) \
|
||||||
K(Bytes, "bytes", 0) \
|
K(Bytes, "bytes", 0) \
|
||||||
K(Byte, "byte", 0) \
|
|
||||||
K(String, "string", 0) \
|
K(String, "string", 0) \
|
||||||
K(Address, "address", 0) \
|
K(Address, "address", 0) \
|
||||||
K(Bool, "bool", 0) \
|
K(Bool, "bool", 0) \
|
||||||
@ -242,6 +241,7 @@ namespace solidity::langutil
|
|||||||
K(Alias, "alias", 0) \
|
K(Alias, "alias", 0) \
|
||||||
K(Apply, "apply", 0) \
|
K(Apply, "apply", 0) \
|
||||||
K(Auto, "auto", 0) \
|
K(Auto, "auto", 0) \
|
||||||
|
K(Byte, "byte", 0) \
|
||||||
K(Case, "case", 0) \
|
K(Case, "case", 0) \
|
||||||
K(CopyOf, "copyof", 0) \
|
K(CopyOf, "copyof", 0) \
|
||||||
K(Default, "default", 0) \
|
K(Default, "default", 0) \
|
||||||
|
@ -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"?
|
Error: No visibility specified. Did you intend to add "public"?
|
||||||
--> too_long_line_multiline/input.sol:2:5:
|
--> 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).
|
| ^ (Relevant source part starts here and spans across multiple lines).
|
||||||
|
|
||||||
Warning: Source file does not specify required compiler version!
|
Warning: Source file does not specify required compiler version!
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
contract C {
|
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;
|
_b = 0x12;
|
||||||
_b2 = 0x1223;
|
_b2 = 0x1223;
|
||||||
_b5 = hex"043245";
|
_b5 = hex"043245";
|
||||||
|
@ -257,7 +257,7 @@ library RLP {
|
|||||||
/// RLPItem is a list.
|
/// RLPItem is a list.
|
||||||
/// @param self The RLPItem.
|
/// @param self The RLPItem.
|
||||||
/// @return data The decoded string.
|
/// @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))
|
if(!isData(self))
|
||||||
revert();
|
revert();
|
||||||
(uint rStartPos, uint len) = _decode(self);
|
(uint rStartPos, uint len) = _decode(self);
|
||||||
@ -267,7 +267,7 @@ library RLP {
|
|||||||
assembly {
|
assembly {
|
||||||
temp := byte(0, mload(rStartPos))
|
temp := byte(0, mload(rStartPos))
|
||||||
}
|
}
|
||||||
return byte(temp);
|
return bytes1(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Decode an RLPItem into an int. This will not work if the
|
/// @dev Decode an RLPItem into an int. This will not work if the
|
||||||
|
@ -2037,7 +2037,7 @@ BOOST_AUTO_TEST_CASE(event_indexed_string)
|
|||||||
for (uint i = 0; i < 90; i++)
|
for (uint i = 0; i < 90; i++)
|
||||||
bytes(x).push(0);
|
bytes(x).push(0);
|
||||||
for (uint8 i = 0; i < 90; i++)
|
for (uint8 i = 0; i < 90; i++)
|
||||||
bytes(x)[i] = byte(i);
|
bytes(x)[i] = bytes1(i);
|
||||||
y[0] = 4;
|
y[0] = 4;
|
||||||
y[1] = 5;
|
y[1] = 5;
|
||||||
y[2] = 6;
|
y[2] = 6;
|
||||||
@ -3421,9 +3421,9 @@ BOOST_AUTO_TEST_CASE(library_call)
|
|||||||
BOOST_AUTO_TEST_CASE(library_function_external)
|
BOOST_AUTO_TEST_CASE(library_function_external)
|
||||||
{
|
{
|
||||||
char const* sourceCode = R"(
|
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 {
|
contract Test {
|
||||||
function f(bytes memory b) public pure returns (byte) {
|
function f(bytes memory b) public pure returns (bytes1) {
|
||||||
return Lib.m(b);
|
return Lib.m(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3786,7 +3786,7 @@ BOOST_AUTO_TEST_CASE(short_strings)
|
|||||||
if (data1[0] != "1") return 10;
|
if (data1[0] != "1") return 10;
|
||||||
if (data1[4] != "4") return 11;
|
if (data1[4] != "4") return 11;
|
||||||
for (uint i = 0; i < data1.length; i ++)
|
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[4]) != 4 * 3) return 12;
|
||||||
if (uint8(data1[67]) != 67 * 3) return 13;
|
if (uint8(data1[67]) != 67 * 3) return 13;
|
||||||
// change length: long -> short
|
// change length: long -> short
|
||||||
|
@ -679,7 +679,7 @@ BOOST_AUTO_TEST_CASE(byte_access)
|
|||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
contract C
|
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) }
|
assembly { r := and(byte(x, 31), 0xff) }
|
||||||
}
|
}
|
||||||
|
@ -491,6 +491,7 @@ BOOST_AUTO_TEST_CASE(keyword_is_reserved)
|
|||||||
"alias",
|
"alias",
|
||||||
"apply",
|
"apply",
|
||||||
"auto",
|
"auto",
|
||||||
|
"byte",
|
||||||
"case",
|
"case",
|
||||||
"copyof",
|
"copyof",
|
||||||
"default",
|
"default",
|
||||||
|
@ -51,7 +51,6 @@ BOOST_AUTO_TEST_CASE(uint_types)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(byte_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++)
|
for (unsigned i = 1; i <= 32; i++)
|
||||||
BOOST_CHECK(*TypeProvider::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, i, 0)) == *TypeProvider::fixedBytes(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(),
|
StringLiteralType(Literal(++id, SourceLocation{}, Token::StringLiteral, make_shared<string>("abc - def"))).identifier(),
|
||||||
"t_stringliteral_196a9142ee0d40e274a6482393c762b16dd8315713207365e1e13d8d85b74fc4"
|
"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("bytes8")->identifier(), "t_bytes8");
|
||||||
BOOST_CHECK_EQUAL(TypeProvider::fromElementaryTypeName("bytes32")->identifier(), "t_bytes32");
|
BOOST_CHECK_EQUAL(TypeProvider::fromElementaryTypeName("bytes32")->identifier(), "t_bytes32");
|
||||||
BOOST_CHECK_EQUAL(TypeProvider::fromElementaryTypeName("bool")->identifier(), "t_bool");
|
BOOST_CHECK_EQUAL(TypeProvider::fromElementaryTypeName("bool")->identifier(), "t_bool");
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
contract C {
|
contract C {
|
||||||
function f(uint a, bytes memory b, uint 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);
|
return (a, b.length, b[3], c);
|
||||||
}
|
}
|
||||||
|
|
||||||
function f_external(uint a, bytes calldata b, uint 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);
|
return (a, b.length, b[3], c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,11 @@ contract C {
|
|||||||
function f(bytes memory a, bytes calldata b, uint[] memory c)
|
function f(bytes memory a, bytes calldata b, uint[] memory c)
|
||||||
external
|
external
|
||||||
pure
|
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]);
|
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);
|
uint[] memory x = new uint[](4);
|
||||||
x[3] = 7;
|
x[3] = 7;
|
||||||
return this.f("abc", "def", x);
|
return this.f("abc", "def", x);
|
||||||
|
@ -2,12 +2,12 @@ pragma abicoder v2;
|
|||||||
|
|
||||||
contract C {
|
contract C {
|
||||||
function f(uint a, bytes memory b, uint 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);
|
return (a, b.length, b[3], c);
|
||||||
}
|
}
|
||||||
|
|
||||||
function f_external(uint a, bytes calldata b, uint 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);
|
return (a, b.length, b[3], c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,11 @@ contract C {
|
|||||||
function f(bytes memory a, bytes calldata b, uint[] memory c)
|
function f(bytes memory a, bytes calldata b, uint[] memory c)
|
||||||
external
|
external
|
||||||
pure
|
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]);
|
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);
|
uint[] memory x = new uint[](4);
|
||||||
x[3] = 7;
|
x[3] = 7;
|
||||||
return this.f("abc", "def", x);
|
return this.f("abc", "def", x);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
contract c {
|
contract c {
|
||||||
byte[10] data1;
|
bytes1[10] data1;
|
||||||
bytes2[32] data2;
|
bytes2[32] data2;
|
||||||
function test() public returns (uint check, uint res1, uint res2) {
|
function test() public returns (uint check, uint res1, uint res2) {
|
||||||
uint i;
|
uint i;
|
||||||
@ -7,7 +7,7 @@ contract c {
|
|||||||
data2[i] = 0xffff;
|
data2[i] = 0xffff;
|
||||||
check = uint(uint16(data2[31])) * 0x10000 | uint(uint16(data2[14]));
|
check = uint(uint16(data2[31])) * 0x10000 | uint(uint16(data2[14]));
|
||||||
for (i = 0; i < data1.length; ++i)
|
for (i = 0; i < data1.length; ++i)
|
||||||
data1[i] = byte(uint8(1 + i));
|
data1[i] = bytes1(uint8(1 + i));
|
||||||
data2 = data1;
|
data2 = data1;
|
||||||
for (i = 0; i < 16; ++i)
|
for (i = 0; i < 16; ++i)
|
||||||
res1 |= uint(uint16(data2[i])) * 0x10000**i;
|
res1 |= uint(uint16(data2[i])) * 0x10000**i;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
contract C {
|
contract C {
|
||||||
bytes s;
|
bytes s;
|
||||||
function f() external returns (byte) {
|
function f() external returns (bytes1) {
|
||||||
bytes memory data = "abcd";
|
bytes memory data = "abcd";
|
||||||
s = data;
|
s = data;
|
||||||
return s[0];
|
return s[0];
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
contract C {
|
contract C {
|
||||||
bytes s = "abcd";
|
bytes s = "abcd";
|
||||||
function f() external returns (byte) {
|
function f() external returns (bytes1) {
|
||||||
bytes memory data = s;
|
bytes memory data = s;
|
||||||
return data[0];
|
return data[0];
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ contract c {
|
|||||||
function f(uint len) public returns (bytes memory) {
|
function f(uint len) public returns (bytes memory) {
|
||||||
bytes memory x = new bytes(len);
|
bytes memory x = new bytes(len);
|
||||||
for (uint i = 0; i < len; i++)
|
for (uint i = 0; i < len; i++)
|
||||||
x[i] = byte(uint8(i));
|
x[i] = bytes1(uint8(i));
|
||||||
a = x;
|
a = x;
|
||||||
for (uint i = 0; i < len; i++)
|
for (uint i = 0; i < len; i++)
|
||||||
assert(a[i] == x[i]);
|
assert(a[i] == x[i]);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
contract C {
|
contract C {
|
||||||
bytes s;
|
bytes s;
|
||||||
function f(bytes calldata data) external returns (byte) {
|
function f(bytes calldata data) external returns (bytes1) {
|
||||||
s = data;
|
s = data;
|
||||||
return s[0];
|
return s[0];
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
contract C {
|
contract C {
|
||||||
bytes data;
|
bytes data;
|
||||||
bytes otherData;
|
bytes otherData;
|
||||||
function fromMemory() public returns (byte) {
|
function fromMemory() public returns (bytes1) {
|
||||||
bytes memory t;
|
bytes memory t;
|
||||||
uint[2] memory x;
|
uint[2] memory x;
|
||||||
x[0] = type(uint).max;
|
x[0] = type(uint).max;
|
||||||
@ -9,12 +9,12 @@ contract C {
|
|||||||
data.push();
|
data.push();
|
||||||
return data[0];
|
return data[0];
|
||||||
}
|
}
|
||||||
function fromCalldata(bytes calldata x) public returns (byte) {
|
function fromCalldata(bytes calldata x) public returns (bytes1) {
|
||||||
data = x;
|
data = x;
|
||||||
data.push();
|
data.push();
|
||||||
return data[0];
|
return data[0];
|
||||||
}
|
}
|
||||||
function fromStorage() public returns (byte) {
|
function fromStorage() public returns (bytes1) {
|
||||||
// zero-length but dirty higher order bits
|
// zero-length but dirty higher order bits
|
||||||
assembly { sstore(otherData.slot, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00) }
|
assembly { sstore(otherData.slot, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00) }
|
||||||
data = otherData;
|
data = otherData;
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
contract Main {
|
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];
|
c1 = _s1[i1];
|
||||||
c2 = intern(_s1, i2);
|
c2 = intern(_s1, i2);
|
||||||
c3 = internIndirect(_s1)[i3];
|
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];
|
return _s1[i];
|
||||||
}
|
}
|
||||||
function internIndirect(bytes memory _s1) public returns (bytes memory) {
|
function internIndirect(bytes memory _s1) public returns (bytes memory) {
|
||||||
|
@ -12,7 +12,7 @@ contract C {
|
|||||||
function abiEncode() public view returns (bytes memory) { return x; }
|
function abiEncode() public view returns (bytes memory) { return x; }
|
||||||
function abiEncodePacked() public view returns (bytes memory) { return abi.encodePacked(x); }
|
function abiEncodePacked() public view returns (bytes memory) { return abi.encodePacked(x); }
|
||||||
function copyToMemory() public view returns (bytes memory m) { m = 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 assignTo() public { x = "def"; }
|
||||||
function assignToLong() public { x = "1234567890123456789012345678901234567"; }
|
function assignToLong() public { x = "1234567890123456789012345678901234567"; }
|
||||||
function copyToStorage() public { y = x; }
|
function copyToStorage() public { y = x; }
|
||||||
|
@ -5,9 +5,9 @@ contract c {
|
|||||||
bytes data;
|
bytes data;
|
||||||
function test() public returns (bool) {
|
function test() public returns (bool) {
|
||||||
for (uint8 i = 0; i <= 40; i++)
|
for (uint8 i = 0; i <= 40; i++)
|
||||||
data.push(byte(i+1));
|
data.push(bytes1(i+1));
|
||||||
for (int8 j = 40; j >= 0; j--) {
|
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));
|
require(data.length == uint8(j+1));
|
||||||
data.pop();
|
data.pop();
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ contract CalldataTest {
|
|||||||
function test(bytes calldata x) public returns (bytes calldata) {
|
function test(bytes calldata x) public returns (bytes calldata) {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
function tester(bytes calldata x) public returns (byte) {
|
function tester(bytes calldata x) public returns (bytes1) {
|
||||||
return this.test(x)[2];
|
return this.test(x)[2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
contract C {
|
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];
|
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);
|
return f(b, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
contract C {
|
contract C {
|
||||||
function(bytes calldata) returns (byte) x;
|
function(bytes calldata) returns (bytes1) x;
|
||||||
constructor() { x = f; }
|
constructor() { x = f; }
|
||||||
function f(bytes calldata b) internal pure returns (byte) {
|
function f(bytes calldata b) internal pure returns (bytes1) {
|
||||||
return b[2];
|
return b[2];
|
||||||
}
|
}
|
||||||
function h(bytes calldata b) external returns (byte) {
|
function h(bytes calldata b) external returns (bytes1) {
|
||||||
return x(b);
|
return x(b);
|
||||||
}
|
}
|
||||||
function g() external returns (byte) {
|
function g() external returns (bytes1) {
|
||||||
bytes memory a = new bytes(34);
|
bytes memory a = new bytes(34);
|
||||||
a[2] = byte(uint8(7));
|
a[2] = bytes1(uint8(7));
|
||||||
return this.h(a);
|
return this.h(a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
library L {
|
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];
|
return _x[2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contract C {
|
contract C {
|
||||||
function f(bytes calldata a)
|
function f(bytes calldata a)
|
||||||
external
|
external
|
||||||
returns (byte)
|
returns (bytes1)
|
||||||
{
|
{
|
||||||
return L.f(3, a, 9);
|
return L.f(3, a, 9);
|
||||||
}
|
}
|
||||||
function g() public returns (byte) {
|
function g() public returns (bytes1) {
|
||||||
bytes memory x = new bytes(4);
|
bytes memory x = new bytes(4);
|
||||||
x[2] = 0x08;
|
x[2] = 0x08;
|
||||||
return this.f(x);
|
return this.f(x);
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
contract C {
|
contract C {
|
||||||
function f(bytes memory _a, bytes calldata _b, bytes memory _c)
|
function f(bytes memory _a, bytes calldata _b, bytes memory _c)
|
||||||
public
|
public
|
||||||
returns (uint, byte, byte, byte)
|
returns (uint, bytes1, bytes1, bytes1)
|
||||||
{
|
{
|
||||||
return (_a.length + _b.length + _c.length, _a[1], _b[1], _c[1]);
|
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 x = new bytes(3);
|
||||||
bytes memory y = new bytes(4);
|
bytes memory y = new bytes(4);
|
||||||
bytes memory z = new bytes(7);
|
bytes memory z = new bytes(7);
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
contract C {
|
contract C {
|
||||||
address constant e = 0x1212121212121212121212121000002134593163;
|
address constant e = 0x1212121212121212121212121000002134593163;
|
||||||
|
|
||||||
function f() public returns (byte z) {
|
function f() public returns (bytes1 z) {
|
||||||
assembly { z := e }
|
assembly { z := e }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ contract Base {
|
|||||||
m_x = x;
|
m_x = x;
|
||||||
m_s = s;
|
m_s = s;
|
||||||
}
|
}
|
||||||
function part(uint i) public returns (byte) {
|
function part(uint i) public returns (bytes1) {
|
||||||
return m_s[i];
|
return m_s[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -16,7 +16,7 @@ contract Main is Base {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
contract Creator {
|
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);
|
Main c = new Main(s, x);
|
||||||
r = c.m_x();
|
r = c.m_x();
|
||||||
ch = c.part(x);
|
ch = c.part(x);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
contract C {
|
contract C {
|
||||||
function f(bytes calldata b) public returns (bool correct) {
|
function f(bytes calldata b) public returns (bool correct) {
|
||||||
byte a = b[3];
|
bytes1 a = b[3];
|
||||||
uint r;
|
uint r;
|
||||||
assembly {
|
assembly {
|
||||||
r := a
|
r := a
|
||||||
|
@ -9,7 +9,7 @@ library D {
|
|||||||
|
|
||||||
contract C {
|
contract C {
|
||||||
using D for bytes;
|
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]);
|
return (_x.f()[0], _x.g()[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ library D {
|
|||||||
|
|
||||||
contract C {
|
contract C {
|
||||||
using D for bytes;
|
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]);
|
return (_x.f()[0], _x.g()[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
library D {
|
library D {
|
||||||
function f(bytes calldata _x) internal pure returns (byte) {
|
function f(bytes calldata _x) internal pure returns (bytes1) {
|
||||||
return _x[0];
|
return _x[0];
|
||||||
}
|
}
|
||||||
function g(bytes memory _x) internal pure returns (byte) {
|
function g(bytes memory _x) internal pure returns (bytes1) {
|
||||||
return _x[0];
|
return _x[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contract C {
|
contract C {
|
||||||
using D for bytes;
|
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());
|
return (_x.f(), _x.g());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
library D {
|
library D {
|
||||||
function f(bytes calldata _x) public pure returns (byte) {
|
function f(bytes calldata _x) public pure returns (bytes1) {
|
||||||
return _x[0];
|
return _x[0];
|
||||||
}
|
}
|
||||||
function g(bytes memory _x) public pure returns (byte) {
|
function g(bytes memory _x) public pure returns (bytes1) {
|
||||||
return _x[0];
|
return _x[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contract C {
|
contract C {
|
||||||
using D for bytes;
|
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());
|
return (_x.f(), _x.g());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ pragma abicoder v2;
|
|||||||
|
|
||||||
contract C
|
contract C
|
||||||
{
|
{
|
||||||
function f() public pure returns (uint, byte, byte) {
|
function f() public pure returns (uint, bytes1, bytes1) {
|
||||||
bytes memory encoded = abi.encodePacked("\\\\");
|
bytes memory encoded = abi.encodePacked("\\\\");
|
||||||
return (encoded.length, encoded[0], encoded[1]);
|
return (encoded.length, encoded[0], encoded[1]);
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ contract C {
|
|||||||
function f(S1 calldata s1)
|
function f(S1 calldata s1)
|
||||||
external
|
external
|
||||||
pure
|
pure
|
||||||
returns (uint256 a, uint64 b0, byte b1, uint256 c)
|
returns (uint256 a, uint64 b0, bytes1 b1, uint256 c)
|
||||||
{
|
{
|
||||||
a = s1.a;
|
a = s1.a;
|
||||||
b0 = s1.s.a;
|
b0 = s1.s.a;
|
||||||
|
@ -7,7 +7,7 @@ contract C {
|
|||||||
bytes2 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;
|
S memory m = s;
|
||||||
return (m.a, m.b, m.c[1]);
|
return (m.a, m.b, m.c[1]);
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ contract C {
|
|||||||
uint[153] r;
|
uint[153] r;
|
||||||
S s;
|
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;
|
s = c;
|
||||||
return (s.a, s.b, s.c[1]);
|
return (s.a, s.b, s.c[1]);
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ contract C {
|
|||||||
function f(S calldata c)
|
function f(S calldata c)
|
||||||
external
|
external
|
||||||
pure
|
pure
|
||||||
returns (uint256, byte, byte, uint256)
|
returns (uint256, bytes1, bytes1, uint256)
|
||||||
{
|
{
|
||||||
S memory m = c;
|
S memory m = c;
|
||||||
return (m.a, m.b[0], m.b[1], m.c);
|
return (m.a, m.b[0], m.b[1], m.c);
|
||||||
|
@ -16,7 +16,7 @@ contract c {
|
|||||||
delete data1;
|
delete data1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
function test(uint256 i) public returns (byte) {
|
function test(uint256 i) public returns (bytes1) {
|
||||||
return data1.data[i];
|
return data1.data[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ contract C {
|
|||||||
assembly {
|
assembly {
|
||||||
sstore(b.slot, or("deadbeef", 0x08))
|
sstore(b.slot, or("deadbeef", 0x08))
|
||||||
}
|
}
|
||||||
byte s = b[3];
|
bytes1 s = b[3];
|
||||||
uint r;
|
uint r;
|
||||||
assembly {
|
assembly {
|
||||||
r := s
|
r := s
|
||||||
|
@ -6,7 +6,7 @@ contract C {
|
|||||||
mstore(0, b.slot)
|
mstore(0, b.slot)
|
||||||
sstore(keccak256(0, 0x20), "deadbeefdeadbeefdeadbeefdeadbeef")
|
sstore(keccak256(0, 0x20), "deadbeefdeadbeefdeadbeefdeadbeef")
|
||||||
}
|
}
|
||||||
byte s = b[31];
|
bytes1 s = b[31];
|
||||||
uint r;
|
uint r;
|
||||||
assembly {
|
assembly {
|
||||||
r := s
|
r := s
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
contract C {
|
contract C {
|
||||||
uint16 x;
|
uint16 x;
|
||||||
byte y;
|
bytes1 y;
|
||||||
uint16 z;
|
uint16 z;
|
||||||
function f(uint8 a) public returns (uint _x) {
|
function f(uint8 a) public returns (uint _x) {
|
||||||
x = a;
|
x = a;
|
||||||
y = byte(uint8(x) + 1);
|
y = bytes1(uint8(x) + 1);
|
||||||
z = uint8(y) + 1;
|
z = uint8(y) + 1;
|
||||||
x = z + 1;
|
x = z + 1;
|
||||||
_x = x;
|
_x = x;
|
||||||
|
@ -32,9 +32,6 @@ contract C {
|
|||||||
function r_b1() public pure returns (bytes1) {
|
function r_b1() public pure returns (bytes1) {
|
||||||
return ~bytes1(hex"55");
|
return ~bytes1(hex"55");
|
||||||
}
|
}
|
||||||
function r_b() public pure returns (byte) {
|
|
||||||
return ~byte(hex"55");
|
|
||||||
}
|
|
||||||
|
|
||||||
function a_b32() public pure returns (bytes32) {
|
function a_b32() public pure returns (bytes32) {
|
||||||
bytes32 r = ~bytes32(hex"ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00");
|
bytes32 r = ~bytes32(hex"ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00");
|
||||||
@ -56,14 +53,10 @@ contract C {
|
|||||||
bytes4 r = ~bytes4(hex"ff00ff00");
|
bytes4 r = ~bytes4(hex"ff00ff00");
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
function a_b1() public pure returns (byte) {
|
function a_b1() public pure returns (bytes1) {
|
||||||
bytes1 r = ~bytes1(hex"55");
|
bytes1 r = ~bytes1(hex"55");
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
function a_b() public pure returns (byte) {
|
|
||||||
byte r = ~byte(hex"55");
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// ====
|
// ====
|
||||||
// compileViaYul: also
|
// compileViaYul: also
|
||||||
@ -77,11 +70,9 @@ contract C {
|
|||||||
// r_b8() -> 0xff00ff00ff00ff000000000000000000000000000000000000000000000000
|
// r_b8() -> 0xff00ff00ff00ff000000000000000000000000000000000000000000000000
|
||||||
// r_b4() -> 0xff00ff00000000000000000000000000000000000000000000000000000000
|
// r_b4() -> 0xff00ff00000000000000000000000000000000000000000000000000000000
|
||||||
// r_b1() -> 0xaa00000000000000000000000000000000000000000000000000000000000000
|
// r_b1() -> 0xaa00000000000000000000000000000000000000000000000000000000000000
|
||||||
// r_b() -> 0xaa00000000000000000000000000000000000000000000000000000000000000
|
|
||||||
// a_b32() -> 0xff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff
|
// a_b32() -> 0xff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff
|
||||||
// a_b25() -> 0xff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff0000000000000000
|
// a_b25() -> 0xff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff0000000000000000
|
||||||
// a_b16() -> 0xff00ff00ff00ff00ff00ff00ff00ff00000000000000000000000000000000
|
// a_b16() -> 0xff00ff00ff00ff00ff00ff00ff00ff00000000000000000000000000000000
|
||||||
// a_b8() -> 0xff00ff00ff00ff000000000000000000000000000000000000000000000000
|
// a_b8() -> 0xff00ff00ff00ff000000000000000000000000000000000000000000000000
|
||||||
// a_b4() -> 0xff00ff00000000000000000000000000000000000000000000000000000000
|
// a_b4() -> 0xff00ff00000000000000000000000000000000000000000000000000000000
|
||||||
// a_b1() -> 0xaa00000000000000000000000000000000000000000000000000000000000000
|
// a_b1() -> 0xaa00000000000000000000000000000000000000000000000000000000000000
|
||||||
// a_b() -> 0xaa00000000000000000000000000000000000000000000000000000000000000
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
pragma experimental SMTChecker;
|
pragma experimental SMTChecker;
|
||||||
|
|
||||||
contract C {
|
contract C {
|
||||||
byte public x;
|
bytes1 public x;
|
||||||
bytes3 public y;
|
bytes3 public y;
|
||||||
|
|
||||||
function f() public view {
|
function f() public view {
|
||||||
byte a = this.x();
|
bytes1 a = this.x();
|
||||||
bytes3 b = this.y();
|
bytes3 b = this.y();
|
||||||
assert(a == x); // should hold
|
assert(a == x); // should hold
|
||||||
assert(a == 'a'); // should fail
|
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: (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: (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: (260-278): CHC: Assertion violation happens here.\nCounterexample:\nx = 0, y = 0\n\n\n\nTransaction trace:\nconstructor()\nState: x = 0, y = 0\nf()
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
pragma experimental SMTChecker;
|
pragma experimental SMTChecker;
|
||||||
contract C {
|
contract C {
|
||||||
function f() public pure {
|
function f() public pure {
|
||||||
assert(byte("") & ("") == byte(0)); // should hold
|
assert(bytes1("") & ("") == bytes1(0)); // should hold
|
||||||
assert(byte(0xAA) & byte(0x55) == byte(0)); // should hold
|
assert(bytes1(0xAA) & bytes1(0x55) == bytes1(0)); // should hold
|
||||||
assert(byte(0xFF) & byte(0xAA) == byte(0xAA)); // should hold
|
assert(bytes1(0xFF) & bytes1(0xAA) == bytes1(0xAA)); // should hold
|
||||||
assert(byte(0xFF) & byte(0xAA) == byte(0)); // should fail
|
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()
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
pragma experimental SMTChecker;
|
pragma experimental SMTChecker;
|
||||||
contract C {
|
contract C {
|
||||||
function f() public pure returns (byte) {
|
function f() public pure returns (bytes1) {
|
||||||
byte b = (byte(0x0F) | (byte(0xF0)));
|
bytes1 b = (bytes1(0x0F) | (bytes1(0xF0)));
|
||||||
assert(b == byte(0xFF)); // should hold
|
assert(b == bytes1(0xFF)); // should hold
|
||||||
assert(b == byte(0x00)); // should fail
|
assert(b == bytes1(0x00)); // should fail
|
||||||
return b;
|
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()
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
pragma experimental SMTChecker;
|
pragma experimental SMTChecker;
|
||||||
contract Simp {
|
contract Simp {
|
||||||
function f3() public pure returns (byte) {
|
function f3() public pure returns (bytes1) {
|
||||||
bytes memory y = "def";
|
bytes memory y = "def";
|
||||||
assert(y[0] ^ "e" != byte(0)); // should hold
|
assert(y[0] ^ "e" != bytes1(0)); // should hold
|
||||||
assert(y[1] ^ "e" != byte(0)); // should fail
|
assert(y[1] ^ "e" != bytes1(0)); // should fail
|
||||||
return y[0];
|
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()
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
pragma experimental SMTChecker;
|
pragma experimental SMTChecker;
|
||||||
contract C {
|
contract C {
|
||||||
function f() public pure returns (byte) {
|
function f() public pure returns (bytes1) {
|
||||||
byte a = 0xff;
|
bytes1 a = 0xff;
|
||||||
byte b = 0xf0;
|
bytes1 b = 0xf0;
|
||||||
a &= b;
|
a &= b;
|
||||||
assert(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 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: (203-217): CHC: Assertion violation happens here.\nCounterexample:\n\n\n = 0\n\nTransaction trace:\nconstructor()\nf()
|
// Warning 6328: (209-223): CHC: Assertion violation happens here.\nCounterexample:\n\n\n = 0\n\nTransaction trace:\nconstructor()\nf()
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
pragma experimental SMTChecker;
|
pragma experimental SMTChecker;
|
||||||
contract C {
|
contract C {
|
||||||
function f() public pure returns (byte) {
|
function f() public pure returns (bytes1) {
|
||||||
byte a = 0xff;
|
bytes1 a = 0xff;
|
||||||
byte b = 0xf0;
|
bytes1 b = 0xf0;
|
||||||
b |= a;
|
b |= a;
|
||||||
assert(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 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: (203-217): CHC: Assertion violation happens here.\nCounterexample:\n\n\n = 0\n\nTransaction trace:\nconstructor()\nf()
|
// Warning 6328: (209-223): CHC: Assertion violation happens here.\nCounterexample:\n\n\n = 0\n\nTransaction trace:\nconstructor()\nf()
|
||||||
|
@ -10,7 +10,7 @@ contract C {
|
|||||||
assert(y[0] == "d"); // fails
|
assert(y[0] == "d"); // fails
|
||||||
|
|
||||||
y[0] ^= "f";
|
y[0] ^= "f";
|
||||||
assert(y[0] == (byte("d") | byte("e")) ^ byte("f"));
|
assert(y[0] == (bytes1("d") | bytes1("e")) ^ bytes1("f"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
pragma experimental SMTChecker;
|
pragma experimental SMTChecker;
|
||||||
contract C {
|
contract C {
|
||||||
function f() public pure returns (byte) {
|
function f() public pure returns (bytes1) {
|
||||||
byte a = 0xff;
|
bytes1 a = 0xff;
|
||||||
byte b = 0xf0;
|
bytes1 b = 0xf0;
|
||||||
a ^= ~b;
|
a ^= ~b;
|
||||||
assert(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 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: (204-221): CHC: Assertion violation happens here.\nCounterexample:\n\n\n = 0\n\nTransaction trace:\nconstructor()\nf()
|
// Warning 6328: (210-227): CHC: Assertion violation happens here.\nCounterexample:\n\n\n = 0\n\nTransaction trace:\nconstructor()\nf()
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
pragma experimental SMTChecker;
|
pragma experimental SMTChecker;
|
||||||
|
|
||||||
contract C {
|
contract C {
|
||||||
mapping (byte => uint) map;
|
mapping (bytes1 => uint) map;
|
||||||
function f() public {
|
function f() public {
|
||||||
map[""] = 2;
|
map[""] = 2;
|
||||||
uint x = map[""];
|
uint x = map[""];
|
||||||
g("");
|
g("");
|
||||||
byte b = "";
|
bytes1 b = "";
|
||||||
assert(x == map[b]);
|
assert(x == map[b]);
|
||||||
assert(x == map["x"]);
|
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()
|
||||||
|
@ -4,9 +4,9 @@ contract C {
|
|||||||
function f() public pure {
|
function f() public pure {
|
||||||
bytes memory b = bytes(hex"ffff");
|
bytes memory b = bytes(hex"ffff");
|
||||||
assert(b.length == 2); // should hold
|
assert(b.length == 2); // should hold
|
||||||
assert(b[0] == byte(uint8(255))); // should hold
|
assert(b[0] == bytes1(uint8(255))); // should hold
|
||||||
assert(b[1] == byte(uint8(100))); // should fail
|
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()
|
||||||
|
@ -3,8 +3,8 @@ pragma experimental SMTChecker;
|
|||||||
contract C {
|
contract C {
|
||||||
function f() public pure {
|
function f() public pure {
|
||||||
bytes32 x = 0x00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff;
|
bytes32 x = 0x00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff;
|
||||||
byte z = 0x00;
|
bytes1 z = 0x00;
|
||||||
byte o = 0xff;
|
bytes1 o = 0xff;
|
||||||
assert(x[0] == z);
|
assert(x[0] == z);
|
||||||
assert(x[31] == o);
|
assert(x[31] == o);
|
||||||
assert(x[0] == x[22]);
|
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()
|
||||||
|
@ -3,7 +3,7 @@ pragma experimental SMTChecker;
|
|||||||
contract C {
|
contract C {
|
||||||
function f() public pure {
|
function f() public pure {
|
||||||
bytes4 x = 0x01020304;
|
bytes4 x = 0x01020304;
|
||||||
byte b = 0x02;
|
bytes1 b = 0x02;
|
||||||
assert(x[0] == b); // fails
|
assert(x[0] == b); // fails
|
||||||
assert(x[1] == b);
|
assert(x[1] == b);
|
||||||
assert(x[2] == b); // fails
|
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: (120-137): 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: (171-188): 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: (201-218): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
|
||||||
|
@ -3,7 +3,7 @@ pragma experimental SMTChecker;
|
|||||||
contract C {
|
contract C {
|
||||||
function f() public pure {
|
function f() public pure {
|
||||||
bytes4 x = 0x01020304;
|
bytes4 x = 0x01020304;
|
||||||
byte b = x[3];
|
bytes1 b = x[3];
|
||||||
assert(b == b[0]);
|
assert(b == b[0]);
|
||||||
assert(b == b[0][0]);
|
assert(b == b[0][0]);
|
||||||
assert(b == b[0][0][0][0][0][0][0][0][0][0][0]);
|
assert(b == b[0][0][0][0][0][0][0][0][0][0][0]);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
pragma experimental SMTChecker;
|
pragma experimental SMTChecker;
|
||||||
contract test {
|
contract test {
|
||||||
struct s { uint a; uint b;}
|
struct s { uint a; uint b;}
|
||||||
function f() pure public returns (byte) {
|
function f() pure public returns (bytes1) {
|
||||||
s;
|
s;
|
||||||
s(1,2);
|
s(1,2);
|
||||||
s[7];
|
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 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: (125-126): Statement has no effect.
|
// Warning 6133: (130-131): Statement has no effect.
|
||||||
// Warning 6133: (130-136): Statement has no effect.
|
// Warning 6133: (135-141): Statement has no effect.
|
||||||
// Warning 6133: (140-144): Statement has no effect.
|
// Warning 6133: (145-149): Statement has no effect.
|
||||||
// Warning 6133: (148-152): Statement has no effect.
|
// Warning 6133: (153-157): Statement has no effect.
|
||||||
// Warning 6133: (156-163): Statement has no effect.
|
// Warning 6133: (161-168): Statement has no effect.
|
||||||
// Warning 8364: (140-144): Assertion checker does not yet implement type type(struct test.s memory[7] memory)
|
// Warning 8364: (145-149): 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: (161-168): 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: (145-149): 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: (161-168): Assertion checker does not yet implement type type(uint256[7] memory)
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
contract C {
|
contract C {
|
||||||
byte[32] data1;
|
bytes1[32] data1;
|
||||||
bytes2[10] data2;
|
bytes2[10] data2;
|
||||||
function f() external {
|
function f() external {
|
||||||
data1 = data2;
|
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.
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
// Used to cause ICE
|
// Used to cause ICE
|
||||||
contract C {
|
contract C {
|
||||||
function f() public {
|
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.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
contract C {
|
contract C {
|
||||||
function a() public pure returns(int[0][500] memory) {}
|
function a() public pure returns(int[0][500] memory) {}
|
||||||
function b() public pure returns(uint[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 d() public pure returns(bytes32[0][500] memory) {}
|
||||||
function e() public pure returns(bytes[0][500] memory) {}
|
function e() public pure returns(bytes[0][500] memory) {}
|
||||||
function e() public pure returns(string[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: (52-53): Array with zero length specified.
|
||||||
// TypeError 1406: (111-112): 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: (172-173): Array with zero length specified.
|
||||||
// TypeError 1406: (232-233): Array with zero length specified.
|
// TypeError 1406: (234-235): Array with zero length specified.
|
||||||
// TypeError 1406: (292-293): Array with zero length specified.
|
// TypeError 1406: (294-295): Array with zero length specified.
|
||||||
// TypeError 1406: (353-354): Array with zero length specified.
|
// TypeError 1406: (355-356): Array with zero length specified.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
contract C {
|
contract C {
|
||||||
int[0] a;
|
int[0] a;
|
||||||
uint[0] b;
|
uint[0] b;
|
||||||
byte[0] c;
|
bytes1[0] c;
|
||||||
bytes32[0] d;
|
bytes32[0] d;
|
||||||
bytes[0] e;
|
bytes[0] e;
|
||||||
string[0] f;
|
string[0] f;
|
||||||
@ -9,7 +9,7 @@ contract C {
|
|||||||
// ----
|
// ----
|
||||||
// TypeError 1406: (19-20): Array with zero length specified.
|
// TypeError 1406: (19-20): Array with zero length specified.
|
||||||
// TypeError 1406: (32-33): 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: (47-48): Array with zero length specified.
|
||||||
// TypeError 1406: (61-62): Array with zero length specified.
|
// TypeError 1406: (63-64): Array with zero length specified.
|
||||||
// TypeError 1406: (75-76): Array with zero length specified.
|
// TypeError 1406: (77-78): Array with zero length specified.
|
||||||
// TypeError 1406: (90-91): Array with zero length specified.
|
// TypeError 1406: (92-93): Array with zero length specified.
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
contract test {
|
contract test {
|
||||||
struct s { uint a; uint b;}
|
struct s { uint a; uint b;}
|
||||||
function f() pure public returns (byte) {
|
function f() pure public returns (bytes1) {
|
||||||
s[75555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555];
|
s[75555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555];
|
||||||
s[7];
|
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.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
contract c {
|
contract c {
|
||||||
bytes arr;
|
bytes arr;
|
||||||
function f() public { byte a = arr[0];}
|
function f() public { bytes1 a = arr[0];}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning 2072: (54-60): Unused local variable.
|
// Warning 2072: (54-62): Unused local variable.
|
||||||
// Warning 2018: (32-71): Function state mutability can be restricted to view
|
// Warning 2018: (32-73): Function state mutability can be restricted to view
|
||||||
|
@ -36,15 +36,15 @@ contract C {
|
|||||||
// real is not there yet.
|
// real is not there yet.
|
||||||
|
|
||||||
// array
|
// array
|
||||||
byte[2] memory a;
|
bytes1[2] memory a;
|
||||||
byte[2] memory b;
|
bytes1[2] memory b;
|
||||||
byte[2] memory k = true ? a : b;
|
bytes1[2] memory k = true ? a : b;
|
||||||
k[0] = byte(0); //Avoid unused var warning
|
k[0] = bytes1(0); //Avoid unused var warning
|
||||||
|
|
||||||
bytes memory e;
|
bytes memory e;
|
||||||
bytes memory f;
|
bytes memory f;
|
||||||
bytes memory l = true ? e : 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
|
// fixed bytes
|
||||||
bytes2 c;
|
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: (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
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
contract C {
|
contract C {
|
||||||
function o(byte) public pure {}
|
function o(bytes1) public pure {}
|
||||||
function f() public {
|
function f() public {
|
||||||
o(true ? 99**99 : 99);
|
o(true ? 99**99 : 99);
|
||||||
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 9717: (94-100): 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 9553: (87-105): 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 3703: (130-136): 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 9553: (118-136): 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 9717: (157-163): Invalid mobile type in true expression.
|
||||||
// TypeError 3703: (164-170): Invalid mobile type in false expression.
|
// TypeError 3703: (166-172): Invalid mobile type in false expression.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
contract test {
|
contract test {
|
||||||
struct s { uint a; uint b;}
|
struct s { uint a; uint b;}
|
||||||
function f() pure public returns (byte) {
|
function f() pure public returns (bytes1) {
|
||||||
s;
|
s;
|
||||||
s(1,2);
|
s(1,2);
|
||||||
s[7];
|
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 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: (93-94): Statement has no effect.
|
// Warning 6133: (95-96): Statement has no effect.
|
||||||
// Warning 6133: (98-104): Statement has no effect.
|
// Warning 6133: (100-106): Statement has no effect.
|
||||||
// Warning 6133: (108-112): Statement has no effect.
|
// Warning 6133: (110-114): Statement has no effect.
|
||||||
// Warning 6133: (116-120): Statement has no effect.
|
// Warning 6133: (118-122): Statement has no effect.
|
||||||
// Warning 6133: (124-131): Statement has no effect.
|
// Warning 6133: (126-133): Statement has no effect.
|
||||||
|
@ -5,7 +5,7 @@ contract C {
|
|||||||
int256 payable d;
|
int256 payable d;
|
||||||
uint payable e;
|
uint payable e;
|
||||||
uint256 payable f;
|
uint256 payable f;
|
||||||
byte payable g;
|
bytes1 payable g;
|
||||||
bytes payable h;
|
bytes payable h;
|
||||||
bytes32 payable i;
|
bytes32 payable i;
|
||||||
fixed payable j;
|
fixed payable j;
|
||||||
@ -20,10 +20,10 @@ contract C {
|
|||||||
// ParserError 9106: (85-92): State mutability can only be specified for address types.
|
// 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: (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: (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: (150-157): State mutability can only be specified for address types.
|
||||||
// ParserError 9106: (169-176): State mutability can only be specified for address types.
|
// ParserError 9106: (171-178): State mutability can only be specified for address types.
|
||||||
// ParserError 9106: (192-199): State mutability can only be specified for address types.
|
// ParserError 9106: (194-201): State mutability can only be specified for address types.
|
||||||
// ParserError 9106: (213-220): State mutability can only be specified for address types.
|
// ParserError 9106: (215-222): State mutability can only be specified for address types.
|
||||||
// ParserError 9106: (239-246): State mutability can only be specified for address types.
|
// ParserError 9106: (241-248): State mutability can only be specified for address types.
|
||||||
// ParserError 9106: (261-268): State mutability can only be specified for address types.
|
// ParserError 9106: (263-270): State mutability can only be specified for address types.
|
||||||
// ParserError 9106: (288-295): State mutability can only be specified for address types.
|
// ParserError 9106: (290-297): State mutability can only be specified for address types.
|
||||||
|
@ -5,7 +5,7 @@ contract C {
|
|||||||
function d(int256 payable) public pure {}
|
function d(int256 payable) public pure {}
|
||||||
function e(uint payable) public pure {}
|
function e(uint payable) public pure {}
|
||||||
function f(uint256 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 h(bytes payable) public pure {}
|
||||||
function i(bytes32 payable) public pure {}
|
function i(bytes32 payable) public pure {}
|
||||||
function j(fixed 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: (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: (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: (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: (305-312): State mutability can only be specified for address types.
|
||||||
// ParserError 9106: (348-355): State mutability can only be specified for address types.
|
// ParserError 9106: (350-357): State mutability can only be specified for address types.
|
||||||
// ParserError 9106: (395-402): State mutability can only be specified for address types.
|
// ParserError 9106: (397-404): State mutability can only be specified for address types.
|
||||||
// ParserError 9106: (440-447): State mutability can only be specified for address types.
|
// ParserError 9106: (442-449): State mutability can only be specified for address types.
|
||||||
// ParserError 9106: (490-497): State mutability can only be specified for address types.
|
// ParserError 9106: (492-499): State mutability can only be specified for address types.
|
||||||
// ParserError 9106: (536-543): State mutability can only be specified for address types.
|
// ParserError 9106: (538-545): State mutability can only be specified for address types.
|
||||||
// ParserError 9106: (587-594): State mutability can only be specified for address types.
|
// ParserError 9106: (589-596): State mutability can only be specified for address types.
|
||||||
|
@ -6,7 +6,7 @@ contract C {
|
|||||||
int256 payable d;
|
int256 payable d;
|
||||||
uint payable e;
|
uint payable e;
|
||||||
uint256 payable f;
|
uint256 payable f;
|
||||||
byte payable g;
|
bytes1 payable g;
|
||||||
bytes payable h;
|
bytes payable h;
|
||||||
bytes32 payable i;
|
bytes32 payable i;
|
||||||
fixed payable j;
|
fixed payable j;
|
||||||
@ -22,10 +22,10 @@ contract C {
|
|||||||
// ParserError 9106: (132-139): State mutability can only be specified for address types.
|
// 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: (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: (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: (209-216): State mutability can only be specified for address types.
|
||||||
// ParserError 9106: (232-239): State mutability can only be specified for address types.
|
// ParserError 9106: (234-241): State mutability can only be specified for address types.
|
||||||
// ParserError 9106: (259-266): State mutability can only be specified for address types.
|
// ParserError 9106: (261-268): State mutability can only be specified for address types.
|
||||||
// ParserError 9106: (284-291): State mutability can only be specified for address types.
|
// ParserError 9106: (286-293): State mutability can only be specified for address types.
|
||||||
// ParserError 9106: (314-321): State mutability can only be specified for address types.
|
// ParserError 9106: (316-323): State mutability can only be specified for address types.
|
||||||
// ParserError 9106: (340-347): State mutability can only be specified for address types.
|
// ParserError 9106: (342-349): State mutability can only be specified for address types.
|
||||||
// ParserError 9106: (371-378): State mutability can only be specified for address types.
|
// ParserError 9106: (373-380): State mutability can only be specified for address types.
|
||||||
|
@ -5,7 +5,7 @@ contract C {
|
|||||||
function d() public pure returns (int256 payable) {}
|
function d() public pure returns (int256 payable) {}
|
||||||
function e() public pure returns (uint payable) {}
|
function e() public pure returns (uint payable) {}
|
||||||
function f() public pure returns (uint256 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 h() public pure returns (bytes payable) {}
|
||||||
function i() public pure returns (bytes32 payable) {}
|
function i() public pure returns (bytes32 payable) {}
|
||||||
function j() public pure returns (fixed 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: (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: (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: (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: (394-401): State mutability can only be specified for address types.
|
||||||
// ParserError 9106: (448-455): State mutability can only be specified for address types.
|
// ParserError 9106: (450-457): State mutability can only be specified for address types.
|
||||||
// ParserError 9106: (506-513): State mutability can only be specified for address types.
|
// ParserError 9106: (508-515): State mutability can only be specified for address types.
|
||||||
// ParserError 9106: (562-569): State mutability can only be specified for address types.
|
// ParserError 9106: (564-571): State mutability can only be specified for address types.
|
||||||
// ParserError 9106: (623-630): State mutability can only be specified for address types.
|
// ParserError 9106: (625-632): State mutability can only be specified for address types.
|
||||||
// ParserError 9106: (680-687): State mutability can only be specified for address types.
|
// ParserError 9106: (682-689): State mutability can only be specified for address types.
|
||||||
// ParserError 9106: (742-749): State mutability can only be specified for address types.
|
// ParserError 9106: (744-751): State mutability can only be specified for address types.
|
||||||
|
5
test/libsolidity/syntaxTests/types/byte.sol
Normal file
5
test/libsolidity/syntaxTests/types/byte.sol
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
contract C {
|
||||||
|
byte public a;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// ParserError 9182: (17-21): Function, variable, struct or modifier declaration expected.
|
@ -1,6 +1,5 @@
|
|||||||
contract C {
|
contract C {
|
||||||
byte b = byte(0x01);
|
bytes1 b1 = bytes1(0x01);
|
||||||
bytes1 b1 = b;
|
|
||||||
bytes2 b2 = b1;
|
bytes2 b2 = b1;
|
||||||
bytes3 b3 = b2;
|
bytes3 b3 = b2;
|
||||||
bytes4 b4 = b3;
|
bytes4 b4 = b3;
|
||||||
|
Loading…
Reference in New Issue
Block a user