-
-
Notifications
You must be signed in to change notification settings - Fork 41
✨ refactor: replace std.debug.assert with if (\!condition) unreachable #1796
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Replace all instances of std.debug.assert with explicit if (\!condition) unreachable; pattern across EVM opcode modules for more explicit error handling. Changed files: - src/evm/opcodes/arithmetic.zig - src/evm/opcodes/bitwise.zig - src/evm/opcodes/comparison.zig - src/evm/opcodes/control.zig - src/evm/opcodes/memory.zig - src/evm/opcodes/stack.zig - src/evm/opcodes/storage.zig Original prompt: "Grep src/**/*.zig for any use of std.debug.assert. Instead use if (\!thing) unreachable; which is the same thing. Make a commit. Include this prompt in the commit message. Use emoji conventional commit. You are not allowed to commit unless \`zig build test-all\` passes" 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
WalkthroughAll EVM opcode implementation files have been updated to replace Changes
Sequence Diagram(s)sequenceDiagram
participant VM
participant Stack
VM->>Stack: Check stack.size
alt stack.size < required
VM->>VM: unreachable (abort execution)
else stack.size >= required
VM->>Stack: Pop/peek operands
VM->>VM: Execute opcode logic
VM->>Stack: Push result (if applicable)
end
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (7)
⏰ Context from checks skipped due to timeout of 90000ms (3)
🔇 Additional comments (21)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Description
Replace
std.debug.assert
withif
statements andunreachable
in EVM opcodes implementation. This change maintains the same runtime behavior while making the assertion logic more explicit.The pattern
std.debug.assert(frame.stack.size >= N)
is replaced withif (frame.stack.size < N) unreachable
, and similarlystd.debug.assert(frame.stack.size < Stack.CAPACITY)
is replaced withif (frame.stack.size >= Stack.CAPACITY) unreachable
.Testing
The code changes maintain identical runtime behavior since both approaches (assert vs if+unreachable) result in the same program termination when the condition is violated. This refactoring improves code clarity by making the assertion checks more explicit.
Additional Information
Your ENS/address:
Summary by CodeRabbit
Bug Fixes
Chores