mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
New tests for wildcard assignments.
This commit is contained in:
parent
43ec1699ba
commit
8ee5d3b274
12
test/libsolidity/syntaxTests/tupleAssignments/error_fill.sol
Normal file
12
test/libsolidity/syntaxTests/tupleAssignments/error_fill.sol
Normal 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).
|
@ -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();
|
||||
}
|
||||
}
|
||||
// ----
|
@ -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).
|
@ -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).
|
@ -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).
|
Loading…
Reference in New Issue
Block a user