mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #3976 from ethereum/emptyTupleComponent
Empty tuple components should not be possible
This commit is contained in:
@@ -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.
|
||||
Reference in New Issue
Block a user