mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add `.address and .selector` in inside assembly for external function pointers
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
contract C {
|
||||
function testFunction() external {}
|
||||
|
||||
function testYul() public {
|
||||
function() external fp = this.testFunction;
|
||||
|
||||
uint myOffset;
|
||||
|
||||
assembly {
|
||||
myOffset := fp.offset
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 9272: (173-182): Variables of type function pointer only support ".selector" and ".address".
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
contract C {
|
||||
function testFunction() internal {}
|
||||
|
||||
function testYul() public returns (address adr) {
|
||||
function() internal fp = testFunction;
|
||||
uint selectorValue = 0;
|
||||
|
||||
assembly {
|
||||
adr := fp.address
|
||||
}
|
||||
}
|
||||
function testSol() public returns (address) {
|
||||
return testFunction.address;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 8533: (193-203): Only Variables of type external function pointer support ".selector" and ".address".
|
||||
// TypeError 9582: (267-287): Member "address" not found or not visible after argument-dependent lookup in function ().
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
contract C {
|
||||
function testFunction() internal {}
|
||||
|
||||
function testYul() public returns (uint32) {
|
||||
function() internal fp = testFunction;
|
||||
uint selectorValue = 0;
|
||||
|
||||
assembly {
|
||||
selectorValue := fp.selector
|
||||
}
|
||||
|
||||
return uint32(bytes4(bytes32(selectorValue)));
|
||||
}
|
||||
function testSol() public returns (uint32) {
|
||||
return uint32(testFunction.selector);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 8533: (198-209): Only Variables of type external function pointer support ".selector" and ".address".
|
||||
// TypeError 9582: (329-350): Member "selector" not found or not visible after argument-dependent lookup in function ().
|
||||
Reference in New Issue
Block a user