Skip to content

Allow reverting with signature error Panic(uint) #11792

Open
@hrkrshnn

Description

@hrkrshnn

Currently, solidity doesn't allow defining errors with the following names Panic and Error (note: name, not signature).

There are use cases where reverting with this error would be useful.

One example is in library fixed point implementation. When adding two fixed point numbers overflows, then it's useful to revert with Panic(0x11) to be consistent with how the compiler would revert in such cases. (List of error codes, or Docs)


Possible solutions

  1. @chriseth suggested allowing something like import Panic from std.errors.
  2. Allow defining errors with signature Panic(uint) and Error(string).
  3. Use inline assembly to mimic the error: no need for the compiler to do anything
  4. Use a collision hack. Find <name>(uint) with the same hash as Panic(uint) and similarly for Error(string).

Metadata

Metadata

Assignees

No one assigned

    Labels

    has dependenciesThe PR depends on other PRs that must be merged firstlanguage 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 haveSomething we consider an essential part of Solidity 1.0.

    Type

    No type

    Projects

    Status

    Consider to Promote

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions