Make unwrap() ABI-encode errors on revert#1342
Conversation
abi_static_size_bytes() only handled primitives and structs/tuples, causing encoded_size<T>() to fail at codegen when T is an enum. The extern intrinsic has no body, so when the compile-time constant folding failed, the call fell through to a missing function. Add enum support: discriminant word (32 bytes) + max variant payload, mirroring the pattern in layout::ty_size_bytes.
a4c8e95 to
96d8b38
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 96d8b38267
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
436ecd9 to
9007ea3
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9007ea3491
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9007ea3491
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
9007ea3 to
3f06209
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3f06209dc4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
`Result::unwrap()` now automatically ABI-encodes the error value when reverting, instead of emitting an empty `revert(0, 0)`. A new `panic_with_value<T>` intrinsic carries the error value from `unwrap()` through MIR as `AbortWithValue`. The monomorphizer, where types are concrete, checks whether `T` implements `Encode<Sol> + AbiSize`. If satisfied, the call is rewritten to `std::evm::effects::revert<T>()`, producing ABI-encoded revert data. If not, a compile error is emitted requiring the error type to implement the necessary traits.
3f06209 to
8160761
Compare
Alternative to #1326
Make
unwrap()ABI-encode errors on revertResult::unwrap()now automatically ABI-encodes the error value whenreverting, instead of emitting an empty
revert(0, 0).A new
panic_with_value<T>intrinsic carries the error value fromunwrap()through MIR asAbortWithValue. The monomorphizer, wheretypes are concrete, checks whether
TimplementsEncode<Sol> + AbiSize.If satisfied, the call is rewritten to
std::evm::effects::revert<T>(),producing ABI-encoded revert data. If not, a compile error is emitted
requiring the error type to implement the necessary traits.