mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Control flow for try statements.
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user