solidity icon indicating copy to clipboard operation
solidity copied to clipboard

Function selectors from inherited interfaces are not visible in parent interface

Open mnusurov opened this issue 1 year ago • 3 comments

Description

The following code fails to compile with:

TypeError: Member "b" not found or not visible after argument-dependent lookup in type(contract I2).

pragma solidity 0.8.26;

interface I1 {
    function b() external;
}

interface I2 is I1 {
    function a() external;
}

// ✅ Test 1 -- passes 
contract test_a {
    function a() external view returns (bytes4) {
        return I2.a.selector;
    }
}

// ❌ Test 1 -- should pass
contract test_b {
    function b() external view returns (bytes4) {
        return I2.b.selector;
    }
}

Why?

According to official v0.8.26 documentation,

Interfaces can inherit from other interfaces. This has the same rules as normal inheritance:

mnusurov avatar May 28 '24 15:05 mnusurov

Thanks for the report @mnusurov.

nikola-matic avatar May 29 '24 12:05 nikola-matic

Yeah just ran into this too, would be a good quality of life improvement

smartcontracts avatar Apr 30 '25 16:04 smartcontracts

we ran into this for @0xTwyne contracts. Would be good to fix this.

bunbun295 avatar Apr 30 '25 16:04 bunbun295