Merge remote-tracking branch 'origin/develop' into breaking

This commit is contained in:
chriseth
2020-05-04 18:46:45 +02:00
51 changed files with 720 additions and 140 deletions
+21 -16
View File
@@ -50,6 +50,7 @@ using namespace solidity::langutil;
#define ALSO_VIA_YUL(CODE) \
{ \
{ CODE } \
reset(); \
m_compileViaYul = true; \
{ CODE } \
}
@@ -1058,11 +1059,13 @@ BOOST_AUTO_TEST_CASE(send_ether)
}
}
)";
u256 amount(130);
compileAndRun(sourceCode, amount + 1);
u160 address(23);
ABI_CHECK(callContractFunction("a(address,uint256)", address, amount), encodeArgs(1));
BOOST_CHECK_EQUAL(balanceAt(address), amount);
ALSO_VIA_YUL(
u256 amount(250);
compileAndRun(sourceCode, amount + 1);
u160 address(23);
ABI_CHECK(callContractFunction("a(address,uint256)", address, amount), encodeArgs(1));
BOOST_CHECK_EQUAL(balanceAt(address), amount);
)
}
BOOST_AUTO_TEST_CASE(transfer_ether)
@@ -1088,17 +1091,19 @@ BOOST_AUTO_TEST_CASE(transfer_ether)
}
}
)";
compileAndRun(sourceCode, 0, "B");
u160 const nonPayableRecipient = m_contractAddress;
compileAndRun(sourceCode, 0, "C");
u160 const oogRecipient = m_contractAddress;
compileAndRun(sourceCode, 20, "A");
u160 payableRecipient(23);
ABI_CHECK(callContractFunction("a(address,uint256)", payableRecipient, 10), encodeArgs(10));
BOOST_CHECK_EQUAL(balanceAt(payableRecipient), 10);
BOOST_CHECK_EQUAL(balanceAt(m_contractAddress), 10);
ABI_CHECK(callContractFunction("b(address,uint256)", nonPayableRecipient, 10), encodeArgs());
ABI_CHECK(callContractFunction("b(address,uint256)", oogRecipient, 10), encodeArgs());
ALSO_VIA_YUL(
compileAndRun(sourceCode, 0, "B");
u160 const nonPayableRecipient = m_contractAddress;
compileAndRun(sourceCode, 0, "C");
u160 const oogRecipient = m_contractAddress;
compileAndRun(sourceCode, 20, "A");
u160 payableRecipient(23);
ABI_CHECK(callContractFunction("a(address,uint256)", payableRecipient, 10), encodeArgs(10));
BOOST_CHECK_EQUAL(balanceAt(payableRecipient), 10);
BOOST_CHECK_EQUAL(balanceAt(m_contractAddress), 10);
ABI_CHECK(callContractFunction("b(address,uint256)", nonPayableRecipient, 10), encodeArgs());
ABI_CHECK(callContractFunction("b(address,uint256)", oogRecipient, 10), encodeArgs());
)
}
BOOST_AUTO_TEST_CASE(uncalled_blockhash)
@@ -18,6 +18,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f(uint256): 0 -> FAILURE
// g(uint256): 0 -> FAILURE
@@ -0,0 +1,17 @@
contract C {
function f() public returns(bytes32) {
return blockhash(1);
}
function g() public returns(bytes32) {
return blockhash(2);
}
function h() public returns(bytes32) {
return blockhash(3);
}
}
// ====
// compileViaYul: also
// ----
// f() -> 0x3737373737373737373737373737373737373737373737373737373737373738
// g() -> 0x3737373737373737373737373737373737373737373737373737373737373739
// h() -> 0x373737373737373737373737373737373737373737373737373737373737373a
@@ -0,0 +1,12 @@
// Test for regression of https://github.com/ethereum/solidity/issues/8406
contract C {
address constant e = 0x1212121212121212121212121000002134593163;
function f() public returns (byte z) {
assembly { z := e }
}
}
// ----
// f() -> 0x00
@@ -4,5 +4,7 @@ contract A {
return a;
}
}
// ====
// compileViaYul: also
// ----
// f() -> 2
@@ -1,5 +1,7 @@
contract C {
uint immutable public x = 1;
}
// ====
// compileViaYul: also
// ----
// x() -> 1
@@ -26,5 +26,7 @@ contract D is B, C {
return (a, b, c, d);
}
}
// ====
// compileViaYul: also
// ----
// f() -> 4, 3, 2, 1
@@ -10,6 +10,8 @@ contract C {
return z();
}
}
// ====
// compileViaYul: also
// ----
// f() -> 7
// callZ() -> 7
@@ -9,5 +9,7 @@ contract C {
return (x+x,y);
}
}
// ====
// compileViaYul: also
// ----
// f() -> 84, 23
@@ -13,6 +13,8 @@ contract C {
return (x+x,y);
}
}
// ====
// compileViaYul: also
// ----
// constructor(): 3 ->
// f() -> 84, 23
@@ -0,0 +1,9 @@
contract C
{
function f() public
{
int x = ~(0,);
}
}
// ----
// TypeError: (60-64): Tuple component cannot be empty.
@@ -0,0 +1,9 @@
contract C
{
function f() public
{
int x = --(,);
}
}
// ----
// TypeError: (59-64): Unary operator -- cannot be applied to type tuple(,)
@@ -0,0 +1,10 @@
contract C
{
function f() public
{
int x = delete (,0);
}
}
// ----
// TypeError: (68-69): Expression has to be an lvalue.
// TypeError: (59-70): Unary operator delete cannot be applied to type tuple(,int_const 0)
@@ -0,0 +1,9 @@
contract C
{
function f() public
{
(int x) = ++(,);
}
}
// ----
// TypeError: (61-66): Unary operator ++ cannot be applied to type tuple(,)
@@ -0,0 +1,20 @@
contract C
{
function f() public
{
int x = +(0, 0);
int y = -(0, 0);
(int z) = ~(0, 0);
(int t) = !(0, 0);
}
}
// ----
// SyntaxError: (59-66): Use of unary + is disallowed.
// TypeError: (59-66): Unary operator + cannot be applied to type tuple(int_const 0,int_const 0)
// TypeError: (51-66): Different number of components on the left hand side (1) than on the right hand side (2).
// TypeError: (84-91): Unary operator - cannot be applied to type tuple(int_const 0,int_const 0)
// TypeError: (76-91): Different number of components on the left hand side (1) than on the right hand side (2).
// TypeError: (111-118): Unary operator ~ cannot be applied to type tuple(int_const 0,int_const 0)
// TypeError: (101-118): Different number of components on the left hand side (1) than on the right hand side (2).
// TypeError: (138-145): Unary operator ! cannot be applied to type tuple(int_const 0,int_const 0)
// TypeError: (128-145): Different number of components on the left hand side (1) than on the right hand side (2).
@@ -0,0 +1,11 @@
contract C {
function f() public pure {
assembly {
setimmutable("abc", 0)
loadimmutable("abc")
}
}
}
// ----
// DeclarationError: (63-75): Function not found.
// DeclarationError: (92-105): Function not found.