Update and extend tests for return expressions.

This commit is contained in:
Daniel Kirchner 2018-08-07 20:46:42 +02:00
parent cc83e69469
commit bb518b59aa
8 changed files with 84 additions and 28 deletions

View File

@ -1,14 +0,0 @@
contract C {
struct S { bool f; }
S s;
function f() internal pure returns (S storage) { return; }
function g() internal view returns (S storage c, S storage) { c = s; return; }
function h() internal view returns (S storage, S storage d) { d = s; return; }
function i() internal pure returns (S storage, S storage) { return; }
}
// ----
// TypeError: (87-88): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
// TypeError: (163-164): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
// TypeError: (233-234): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
// TypeError: (316-317): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
// TypeError: (327-328): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.

View File

@ -1,7 +0,0 @@
contract C {
struct S { bool f; }
S s;
function f() internal view returns (S storage c, S storage d) { c = s; d = s; return; }
function g() internal view returns (S storage, S storage) { return (s,s); }
}
// ----

View File

@ -1,7 +0,0 @@
contract C {
function f() pure public returns (uint a) {
return;
}
}
// ----
// Warning: (51-57): Unused function parameter. Remove or comment out the variable name to silence this warning.

View File

@ -0,0 +1,14 @@
contract C
{
function f() public pure returns (uint)
{
return;
}
function g() public pure returns (uint)
{
return (1, 2);
}
}
// ----
// TypeError: (71-78): Return arguments required.
// TypeError: (143-156): Different number of arguments in return statement than in returns declaration.

View File

@ -0,0 +1,14 @@
contract C
{
function f() public pure returns (uint a)
{
return;
}
function g() public pure returns (uint a)
{
return (1, 2);
}
}
// ----
// TypeError: (73-80): Return arguments required.
// TypeError: (147-160): Different number of arguments in return statement than in returns declaration.

View File

@ -0,0 +1,19 @@
contract C
{
function f() public pure returns (uint, uint)
{
return 1;
}
function g() public pure returns (uint, uint)
{
return (1, 2, 3);
}
function h() public pure returns (uint, uint)
{
return;
}
}
// ----
// TypeError: (77-85): Different number of arguments in return statement than in returns declaration.
// TypeError: (157-173): Different number of arguments in return statement than in returns declaration.
// TypeError: (245-252): Return arguments required.

View File

@ -0,0 +1,19 @@
contract C
{
function f() public pure returns (uint a, uint b)
{
return 1;
}
function g() public pure returns (uint a, uint b)
{
return (1, 2, 3);
}
function h() public pure returns (uint a, uint b)
{
return;
}
}
// ----
// TypeError: (81-89): Different number of arguments in return statement than in returns declaration.
// TypeError: (165-181): Different number of arguments in return statement than in returns declaration.
// TypeError: (257-264): Return arguments required.

View File

@ -0,0 +1,18 @@
contract C
{
function f() public pure {
return;
}
function g() public pure returns (uint) {
return 1;
}
function h() public pure returns (uint a) {
return 1;
}
function i() public pure returns (uint, uint) {
return (1, 2);
}
function j() public pure returns (uint a, uint b) {
return (1, 2);
}
}