mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Restrict mobile types of function types.
Move ternary tests to semanticTests
This commit is contained in:
committed by
Nikola Matic
parent
2c82873a2c
commit
110e2a656d
@@ -0,0 +1,10 @@
|
||||
contract C {
|
||||
function f() public {}
|
||||
function g() public {}
|
||||
function h(bool c) public returns (bytes4) {
|
||||
return (c ? this.f : this.g).selector;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// h(bool): true -> 0x26121ff000000000000000000000000000000000000000000000000000000000
|
||||
// h(bool): false -> 0xe2179b8e00000000000000000000000000000000000000000000000000000000
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
contract A {
|
||||
function f() public {}
|
||||
function g() public {}
|
||||
}
|
||||
|
||||
contract C {
|
||||
A a = new A();
|
||||
|
||||
function getContract() public view returns (A) {
|
||||
return a;
|
||||
}
|
||||
|
||||
function test(bool b) public view returns (bytes4) {
|
||||
return (b ? getContract().f : getContract().g).selector;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// test(bool): true -> 0x26121ff000000000000000000000000000000000000000000000000000000000
|
||||
// test(bool): false -> 0xe2179b8e00000000000000000000000000000000000000000000000000000000
|
||||
@@ -0,0 +1,10 @@
|
||||
contract C {
|
||||
function f() internal pure returns(uint256) { return 1;}
|
||||
function g() internal pure returns(uint256) { return 2; }
|
||||
function test(bool b) public returns(uint256) {
|
||||
return (b ? C.f : C.g)();
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// test(bool): true -> 1
|
||||
// test(bool): false -> 2
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
library L {
|
||||
function f() internal pure returns(uint256){ return 1; }
|
||||
}
|
||||
|
||||
contract C {
|
||||
function g() internal pure returns(uint256) { return 2; }
|
||||
function test(bool b) public returns(uint256) {
|
||||
return (b ? L.f : C.g)();
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// test(bool): true -> 1
|
||||
// test(bool): false -> 2
|
||||
@@ -0,0 +1,10 @@
|
||||
contract C {
|
||||
function f() public pure returns(uint256) { return 1; }
|
||||
function g() public pure returns(uint256) { return 2; }
|
||||
function test(bool b) public returns(uint256) {
|
||||
return (b ? C.f : C.g)();
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// test(bool): true -> 1
|
||||
// test(bool): false -> 2
|
||||
Reference in New Issue
Block a user