solidity/test/libsolidity/semanticTests/viaYul/loops/return.sol

35 lines
629 B
Solidity
Raw Normal View History

2019-04-29 14:38:18 +00:00
contract C {
function f() public returns (uint x) {
x = 1;
uint a;
2019-04-29 14:38:18 +00:00
for (; a < 10; a = a + 1) {
return x;
2019-04-29 14:38:18 +00:00
x = x + x;
}
x = x + a;
}
function g() public returns (uint x) {
2019-04-29 14:38:18 +00:00
x = 1;
uint a;
while (a < 10) {
2019-04-29 14:38:18 +00:00
return x;
x = x + x;
a = a + 1;
2019-04-29 14:38:18 +00:00
}
x = x + a;
}
function h() public returns (uint x) {
x = 1;
do {
x = x + 1;
return x;
} while (x < 3);
}
2019-04-29 14:38:18 +00:00
}
// ====
2019-04-29 14:38:18 +00:00
// compileViaYul: true
// ----
// f() -> 1
// g() -> 1
// h() -> 2