New tests for wildcard assignments.

This commit is contained in:
chriseth 2018-05-04 16:20:38 +02:00 committed by Alex Beregszaszi
parent 43ec1699ba
commit 8ee5d3b274
5 changed files with 66 additions and 0 deletions

View File

@ -0,0 +1,12 @@
pragma experimental "v0.5.0";
contract C {
function f() public pure returns (uint, uint, bytes32) {
uint a;
bytes32 b;
(a,) = f();
(,b) = f();
}
}
// ----
// TypeError: (126-136): Different number of components on the left hand side (2) than on the right hand side (3).
// TypeError: (140-150): Different number of components on the left hand side (2) than on the right hand side (3).

View File

@ -0,0 +1,24 @@
pragma experimental "v0.5.0";
contract C {
function g() public pure returns (
uint,
uint,
uint,
uint,
uint,
uint,
uint,
uint,
uint,
uint,
uint,
uint,
uint
) { }
function f() public pure returns (uint, uint, bytes32) {
uint a;
uint b;
(,,,,a,,,,b,,,,) = g();
}
}
// ----

View File

@ -0,0 +1,8 @@
contract C {
function f() public pure {
uint a;
(a,) = (uint(1),);
}
}
// ----
// Warning: (53-70): Different number of components on the left hand side (2) than on the right hand side (1).

View File

@ -0,0 +1,11 @@
contract C {
function f() public pure returns (uint, uint, bytes32) {
uint a;
bytes32 b;
(a,) = f();
(,b) = f();
}
}
// ----
// Warning: (96-106): Different number of components on the left hand side (2) than on the right hand side (3).
// Warning: (110-120): Different number of components on the left hand side (2) than on the right hand side (3).

View File

@ -0,0 +1,11 @@
contract C {
function f() public pure returns (uint, uint, uint, uint) {
// Can later be replaced by (uint a, uint b,) = f();
var (a,b,) = f();
a; b;
}
}
// ----
// Warning: (136-137): Use of the "var" keyword is deprecated.
// Warning: (138-139): Use of the "var" keyword is deprecated.
// Warning: (131-147): Different number of components on the left hand side (3) than on the right hand side (4).