mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #6787 from ethereum/sol2yul-ctor-code
Improve constructor-code codegen (wrt. state variable initialization)
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user