Control flow for try statements.

This commit is contained in:
chriseth
2019-09-23 17:22:56 +02:00
parent 644a402166
commit b5bc52f2a7
4 changed files with 88 additions and 2 deletions
@@ -0,0 +1,34 @@
contract C {
struct S { bool f; }
S s;
function ext() external {}
function f() internal returns (S storage r)
{
try this.ext() { }
catch (bytes memory) { r = s; }
}
function g() internal returns (S storage r)
{
try this.ext() { r = s; }
catch (bytes memory) { }
}
function h() internal returns (S storage r)
{
try this.ext() {}
catch Error (string memory) { r = s; }
catch (bytes memory) { r = s; }
}
function i() internal returns (S storage r)
{
try this.ext() { r = s; }
catch (bytes memory) { return r; }
r = s;
}
}
// ====
// EVMVersion: >=byzantium
// ----
// TypeError: (113-124): This variable is of storage pointer type and can be returned without prior assignment.
// TypeError: (240-251): This variable is of storage pointer type and can be returned without prior assignment.
// TypeError: (367-378): This variable is of storage pointer type and can be returned without prior assignment.
// TypeError: (631-632): This variable is of storage pointer type and can be accessed without prior assignment.
@@ -0,0 +1,24 @@
contract C {
struct S { bool f; }
S s;
function ext() external { }
function f() internal returns (S storage r)
{
try this.ext() { r = s; }
catch (bytes memory) { r = s; }
}
function g() internal returns (S storage r)
{
try this.ext() { r = s; }
catch Error (string memory) { r = s; }
catch (bytes memory) { r = s; }
}
function h() internal returns (S storage r)
{
try this.ext() { }
catch (bytes memory) { }
r = s;
}
}
// ====
// EVMVersion: >=byzantium