Merge pull request #6787 from ethereum/sol2yul-ctor-code

Improve constructor-code codegen (wrt. state variable initialization)
This commit is contained in:
chriseth
2019-08-05 11:50:34 +02:00
committed by GitHub
6 changed files with 78 additions and 12 deletions
+4 -2
View File
@@ -7921,8 +7921,10 @@ BOOST_AUTO_TEST_CASE(accessor_for_state_variable)
}
)";
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("ticketPrice()"), encodeArgs(u256(500)));
ALSO_VIA_YUL(
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("ticketPrice()"), encodeArgs(u256(500)));
);
}
BOOST_AUTO_TEST_CASE(accessor_for_const_state_variable)
@@ -0,0 +1,14 @@
contract C {
uint public i = 1;
uint public k = 2;
constructor() public {
i = i + i;
k = k - i;
}
}
// ====
// compileViaYul: also
// ----
// i() -> 2
// k() -> 0