Repository navigation
feat(lang): wrapping arithmetic operators -% and *% (R7-loop #3, supersedes #1660) - #1674
Merged
Merged
Conversation
Implements the Zig-style wrapping operator family #1659. Only +% existed (and gen-rust mis-emitted it as literal invalid Rust). Adds -% and *%: - lexer: MinusPercent / StarPercent tokens - parser: -% in additive, *% in multiplicative precedence - Rust backend: +%/-%/*% -> wrapping_add/sub/mul (no infix form in Rust) - Verilog backend: collapse to +/-, *% routes through __mul_noop (HW wraps) - C backend: collapse to +/-/* (C unsigned wraps mod 2^N) - Zig backend: native operators, passed through verbatim (unchanged) Checked +/-/* keep infix -> same overflow-panic semantics as the Zig backend. Adds cross-backend regression test test_wrapping_ops_all_backends_1659 and re-seals FROZEN_HASH (M5). Full suite 1495 passed / 0 failed; generated Rust compiles under rustc; Verilog/C emit no literal %-operator. Supersedes #1660. Closes #1659 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
|
📓 NotebookLM Notebook linked to this PR
This notebook contains session context, decisions, and artifacts for this work. |
Contributor
This was referenced Aug 5, 2026
gHashTag
enabled auto-merge
August 5, 2026 13:36
Contributor
|
📓 NotebookLM Notebook linked to this PR
This notebook contains session context, decisions, and artifacts for this work. |
Contributor
PR DashboardGenerated at: 2026-08-05 13:37:13 UTC
Summary
Seal Status
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the full Zig-style wrapping-operator family (#1659). Previously only
+%existed — andgen-rustmis-emitted it as literal invalid Rust. Hash mixers that need a wrapping multiply had no way to express it, so they used checked*and panicked on debug overflow.Changes
MinusPercent/StarPercenttokens-%additive,*%multiplicative precedencewrapping_add/wrapping_sub/wrapping_mul(no infix form in Rust)+/-;*%routes through__mul_noop(RTL wraps by width)+/-/*(C unsigned wraps mod 2^N)Checked
+/-/*stay infix, so every backend keeps identical overflow-panic semantics.Verification
test_wrapping_ops_all_backends_1659.gen-rustof a*%/+%/-%mixer compiles underrustc; Verilog & C emit 0 literal%-operators.Supersedes #1660 (the minimal
+%-only Rust fix — folded in here).Closes #1659
🤖 Generated with Claude Code