Skip to content

Ability to override function selectors to support external interfaces not expressible in valid syntax. #11819

Open
@ekpyron

Description

@ekpyron

Came up in #11743, earlier in #1687, resp. #8081

We need a way to override function selectors in interfaces for two reasons:

  • We might ourselves add new keywords to the language which might break backwards compatibility with contracts with an entry point with that name.
  • Third-Party languages might allow selectors that collide with keywords or are otherwise incompatible with regular solidity function definitions.

We seem to have pretty much consensus on that we want this, but we require good syntax for it.

One option (I myself dislike) would be a modifier-style decorator at various positions with various names.

interface C
{
  function errorCompat() selector(0x01020304) external returns (uint);
  function errorCompat2() signature("error()") external returns (uint);
}

To me it seems like those are not prominent enough, though, among visiblity and mutability.

We had the idea to use = Base.f; for disambiguating during inheritance at some point, along those lines a possiblity would be:

interface C
{
  function errorCompat() external returns (uint) = "error()";
  function errorCompat2() external returns (uint) = 0x01020304;
}

Might be good to force encapsulation in a call-like construct, e.g. = externalSignature("error()"), but choosing a name for that may be hairy.

Another option would be to borrow from the call option syntax, e.g.

interface C
{
  function{ signature = "error()" } errorCompat() external returns (uint);
  function{ selector = 0x01020304 } errorCompat() external returns (uint);
}

advantage: extensible if we ever need further similar annotations (e.g. if we ever want to break the ABI encoding, we could select a version here). No need for making selector (or anything) a keyword.

Metadata

Metadata

Assignees

No one assigned

    Labels

    language design :rage4:Any changes to the language, e.g. new featureslow effortThere is not much implementation work to be done. The task is very easy or tiny.medium impactDefault level of impactmust have eventuallySomething we consider essential but not enough to prevent us from releasing Solidity 1.0 without it.needs designThe proposal is too vague to be implemented right away

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions