Skip to content

Convert verbatim into a single builtin with literal arguments #15805

Open
@cameel

Description

@cameel

Abstract

Currently we have a separate verbatim_<n>i_<m>o(c, ...) builtin for every combination of n and m. We should replace it with a single verbatim() builtin with the first 3 arguments being literal arguments.

Motivation

The current design complicates the implementation, because it has to be treated specially. Internally all other builtins always exist, while verbatim ones are generated on demand. This became problematic especially after #15520, because it makes it harder to give them fixed locations in an array. We rely on the fact that we can't have more than 10000 of them (m and n are limited to 99), but the limit is artificial and we're even considering lifting it eventually.

Yul builtins can have literal arguments - arguments that must always be literals, not variables or expressions, so that their values are known at compilation time. Such arguments can be used for m and n instead. This seems much simpler both for the implementation and for the user.

Open design questions

  • Should we keep the old names reserved or release them?

Specification

  • Remove verbatim_<n>i_<m>o(c, ...) builtins.
  • Define the equivalent verbatim(n, m, c, ...) builtin:
    • Mark the first 3 arguments as literal arguments.
    • Keep the range restrictions for now.
  • Update the docs.

Backwards Compatibility

This is a breaking change for Yul. Solidity and assembly import are unaffected, because verbatim is not available in inline assembly.

Due to not being available in inline assembly verbatim() does not seem widely used. We decided it does not need a deprecation period. We'll swap one version for another in a breaking release.

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking change ⚠️low effortThere is not much implementation work to be done. The task is very easy or tiny.low impactChanges are not very noticeable or potential benefits are limited.must have eventuallySomething we consider essential but not enough to prevent us from releasing Solidity 1.0 without it.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions