Promote custom errors to proper types. #15388
Labels
high effort
A lot to implement but still doable by a single person. The task is large or difficult.
medium impact
Default level of impact
selected for development
It's on our short-term development
Milestone
We already introduced the ability to use custom errors as second argument for
require
.Ultimately, we can treat custom errors as regular types that can be stored in local variables and passed to functions like normal arguments. This could be done either by introducing a separate type for each custom error or by introducing a generic type
error
- in either case the value would be encoded as abytes memory
containing the abi-encoding of the error. Conceptually, that's also what already happens for "require with custom error".Moving further in this direction will take some work, since it involves thinking about all explicit and implicit conversion behaviour of the new custom error type (as well as the question whether it should be one or several types still needs to be settled).
However, we can already continue in this direction by allowing an explicit conversion from calls to error constructors to
bytes memory
.So as a next step we can allow:
this would solve the use case of #14974 (comment), resp. would supersede #14287
The specification for this first step would be:
Calls to error constructors can still only occur in revert statements, as second argument to require, and (with this change) also as arguments to a type conversion call to
bytes
. The resulting type would bebytes memory
.The text was updated successfully, but these errors were encountered: