mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fixed bad cast when abiEncodeCall receives a tuple from a function.
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
||||
contract C {
|
||||
function g0() internal pure {}
|
||||
function g2() internal pure returns (uint, uint) { return (2, 3); }
|
||||
|
||||
function f0() public {}
|
||||
function f2(uint, uint) public {}
|
||||
|
||||
function h() public view {
|
||||
uint a;
|
||||
uint b;
|
||||
|
||||
abi.encodeCall(this.f0, () = g0());
|
||||
abi.encodeCall(this.f0, () = ());
|
||||
abi.encodeCall(this.f2, (a, b) = g2());
|
||||
abi.encodeCall(this.f2, (a, b) = (2, 3));
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 5547: (284-286): Empty tuple on the left hand side.
|
||||
// TypeError 9062: (284-293): Expected an inline tuple, not an expression of a tuple type.
|
||||
// TypeError 5547: (328-330): Empty tuple on the left hand side.
|
||||
// TypeError 9062: (328-335): Expected an inline tuple, not an expression of a tuple type.
|
||||
// TypeError 9062: (370-383): Expected an inline tuple, not an expression of a tuple type.
|
||||
// TypeError 9062: (418-433): Expected an inline tuple, not an expression of a tuple type.
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
contract C {
|
||||
function g0() internal pure {}
|
||||
function g2() internal pure returns (uint, uint) { return (2, 3); }
|
||||
|
||||
function f0() public {}
|
||||
function f2(uint, uint) public {}
|
||||
|
||||
function h() public view {
|
||||
abi.encodeCall(this.f0, true ? g0() : g0());
|
||||
abi.encodeCall(this.f2, true ? g2() : g2());
|
||||
abi.encodeCall(this.f2, true ? (1, 2) : (3, 4));
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 9062: (251-269): Expected an inline tuple, not an expression of a tuple type.
|
||||
// TypeError 9062: (304-322): Expected an inline tuple, not an expression of a tuple type.
|
||||
// TypeError 9062: (357-379): Expected an inline tuple, not an expression of a tuple type.
|
||||
@@ -0,0 +1,16 @@
|
||||
contract C {
|
||||
event Ev();
|
||||
error Er();
|
||||
|
||||
function f0() public {}
|
||||
|
||||
function h() public view {
|
||||
abi.encodeCall(this.f0, Ev());
|
||||
abi.encodeCall(this.f0, Er());
|
||||
abi.encodeCall(this.f0, revert());
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 9062: (138-142): Expected an inline tuple, not an expression of a tuple type.
|
||||
// TypeError 9062: (177-181): Expected an inline tuple, not an expression of a tuple type.
|
||||
// TypeError 9062: (216-224): Expected an inline tuple, not an expression of a tuple type.
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
contract C {
|
||||
event Ev();
|
||||
error Er();
|
||||
|
||||
function g0() internal pure {}
|
||||
function g2() internal pure returns (uint, uint) { return (2, 3); }
|
||||
|
||||
function f0() public {}
|
||||
function f2(uint, uint) public {}
|
||||
|
||||
function h() public view {
|
||||
abi.encodeCall(this.f2, (1, 1) + (2, 2));
|
||||
abi.encodeCall(this.f0, Ev() / Er());
|
||||
abi.encodeCall(this.f0, !());
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 2271: (284-299): Operator + not compatible with types tuple(int_const 1,int_const 1) and tuple(int_const 2,int_const 2)
|
||||
// TypeError 9062: (284-299): Expected an inline tuple, not an expression of a tuple type.
|
||||
// TypeError 2271: (334-345): Operator / not compatible with types tuple() and tuple()
|
||||
// TypeError 9062: (334-345): Expected an inline tuple, not an expression of a tuple type.
|
||||
// TypeError 4907: (380-383): Unary operator ! cannot be applied to type tuple()
|
||||
// TypeError 9062: (380-383): Expected an inline tuple, not an expression of a tuple type.
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
contract C {
|
||||
function g0() internal pure {}
|
||||
function g2() internal pure returns (uint, uint) { return (2, 3); }
|
||||
|
||||
function f0() public {}
|
||||
function f2(uint, uint) public {}
|
||||
|
||||
function h() public view {
|
||||
abi.encodeCall(this.f0, g0());
|
||||
abi.encodeCall(this.f2, g2());
|
||||
|
||||
abi.encodeCall(this.f0, (g0()));
|
||||
abi.encodeCall(this.f2, (g2()));
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 9062: (251-255): Expected an inline tuple, not an expression of a tuple type.
|
||||
// TypeError 9062: (290-294): Expected an inline tuple, not an expression of a tuple type.
|
||||
// TypeError 6473: (331-335): Tuple component cannot be empty.
|
||||
// TypeError 7788: (306-337): Expected 0 instead of 1 components for the tuple parameter.
|
||||
// TypeError 7788: (347-378): Expected 2 instead of 1 components for the tuple parameter.
|
||||
// TypeError 5407: (372-376): Cannot implicitly convert component at position 0 from "tuple(uint256,uint256)" to "uint256".
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
contract C {
|
||||
function g1() internal pure returns (uint) { return (1); }
|
||||
|
||||
function f1(uint) public {}
|
||||
|
||||
function h() public view {
|
||||
uint a;
|
||||
|
||||
abi.encodeCall(this.f1, (a) = g1());
|
||||
abi.encodeCall(this.f1, (a) = (1));
|
||||
}
|
||||
}
|
||||
// ----
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
contract C {
|
||||
function g1() internal pure returns (uint) { return (1); }
|
||||
|
||||
function f1(uint) public {}
|
||||
|
||||
function h() public view {
|
||||
abi.encodeCall(this.f1, true ? (1) : (2));
|
||||
abi.encodeCall(this.f1, true ? g1() : g1());
|
||||
}
|
||||
}
|
||||
// ----
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
contract C {
|
||||
function g1() internal pure returns (uint) { return (1); }
|
||||
function g2() internal pure returns (uint, uint) { return (2, 3); }
|
||||
|
||||
function f1(uint) public {}
|
||||
function f2(uint, uint) public {}
|
||||
|
||||
function h() public view {
|
||||
abi.encodeCall(this.f1, g1());
|
||||
abi.encodeCall(this.f1, (g1()));
|
||||
abi.encodeCall(this.f2, (g1(), g1()));
|
||||
}
|
||||
}
|
||||
// ----
|
||||
Reference in New Issue
Block a user