Merge pull request #3976 from ethereum/emptyTupleComponent

Empty tuple components should not be possible
This commit is contained in:
chriseth
2018-04-23 17:35:00 +02:00
committed by GitHub
9 changed files with 92 additions and 1 deletions
@@ -0,0 +1,10 @@
pragma solidity ^0.4.3;
contract C {
event SomeEvent();
function a() public {
(SomeEvent(), 7);
}
}
// ----
// Warning: (95-106): Invoking events without "emit" prefix is deprecated.
// Warning: (95-106): Tuple component cannot be empty.
@@ -0,0 +1,10 @@
pragma experimental "v0.5.0";
contract C {
event SomeEvent();
function a() public {
(SomeEvent(), 7);
}
}
// ----
// TypeError: (101-112): Event invocations have to be prefixed by "emit".
// TypeError: (101-112): Tuple component cannot be empty.
@@ -0,0 +1,12 @@
pragma solidity ^0.4.3;
contract C {
function f() private pure {}
function a() public pure {
bool x = true;
bool y = true;
(x) ? (f(), y = false) : (f(), y = false);
}
}
// ----
// Warning: (162-165): Tuple component cannot be empty.
// Warning: (181-184): Tuple component cannot be empty.
@@ -0,0 +1,11 @@
pragma experimental "v0.5.0";
contract C {
function f() private pure {}
function a() public pure {
bool x = true;
bool y = true;
(x) ? (f(), y = false) : (f(), y = false);
}
}
// ----
// TypeError: (168-171): Tuple component cannot be empty.
@@ -0,0 +1,13 @@
pragma solidity ^0.4.3;
contract C {
function f() private pure {}
function a() public {
uint x;
uint y;
(x, y) = (f(), f());
}
}
// ----
// Warning: (146-149): Tuple component cannot be empty.
// Warning: (151-154): Tuple component cannot be empty.
// TypeError: (145-155): Type tuple(tuple(),tuple()) is not implicitly convertible to expected type tuple(uint256,uint256).
@@ -0,0 +1,11 @@
pragma experimental "v0.5.0";
contract C {
function f() private pure {}
function a() public {
uint x;
uint y;
(x, y) = (f(), f());
}
}
// ----
// TypeError: (152-155): Tuple component cannot be empty.
@@ -0,0 +1,11 @@
pragma solidity ^0.4.3;
contract C {
function f() private pure {}
function a() public {
uint x;
uint y;
(x, y) = [f(), f()];
}
}
// ----
// TypeError: (146-149): Array component cannot be empty.