Conversation
The wrapping-add operator +% (Zig-style, TokenKind::PlusPercent) was passed through literally by the Rust emitter, producing `a +% b` — not valid Rust, fails to compile. Lower it to (lhs).wrapping_add(rhs) in Compiler::expr_to_rust. Checked + / * stay infix so the Rust backend keeps the same overflow-panic semantics as the Zig backend (which emits checked +/* and native +%). Adds regression test test_wrapping_add_op_lowered_rust (L4) and re-seals the FROZEN_HASH (M5). Full compiler suite: 1495 passed / 0 failed. Generated code now compiles under rustc --edition 2021. Closes #1658 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Contributor
|
📓 NotebookLM Notebook linked to this PR
This notebook contains session context, decisions, and artifacts for this work. |
Owner
Author
|
Superseded by #1674, which folds in this exact |
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.
Problem
t27c gen-rustemitted the wrapping-add operator+%literally (a +% b), which is not valid Rust and fails to compile.Fix
Lower
+%→(lhs).wrapping_add(rhs)inCompiler::expr_to_rust. Checked+/*deliberately stay infix — the Zig backend keeps them checked (overflow-panic in debug), and the two backends must agree. Blanket backend-wrapping (as the R7 backlog line suggested) would break that parity; see #1659 for the real hash-mixer story (missing*%/-%/<<%operators).Verification
test_wrapping_add_op_lowered_rust:+%→wrapping_add, no literal+%leak, plain+NOT wrapped.bitnet_pipeline::sequencer_idle_arms_on_startfails identically on pristine master — pre-existing, unrelated.)gen-rustoutput now compiles underrustc --edition 2021.Constitution
gen/edit.93cc42e3…).Closes #1658
Relates #1659
🤖 Generated with Claude Code