Restrict mobile types of function types.

Move ternary tests to semanticTests
This commit is contained in:
Daniel Kirchner
2023-07-18 14:13:36 +02:00
committed by Nikola Matic
parent 2c82873a2c
commit 110e2a656d
16 changed files with 153 additions and 37 deletions
@@ -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
@@ -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
@@ -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