Skip to content

feat(lang): wrapping arithmetic operators -% and *% (R7-loop #3, supersedes #1660) - #1674

Merged
gHashTag merged 3 commits into
masterfrom
feat/wrapping-arith-ops
Aug 5, 2026
Merged

gHashTag merged 3 commits into
masterfrom
feat/wrapping-arith-ops

Conversation

@gHashTag

@gHashTag gHashTag commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Implements the full Zig-style wrapping-operator family (#1659). Previously only +% existed — and gen-rust mis-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

Layer +% -% *%
lexer MinusPercent / StarPercent tokens
parser -% additive, *% multiplicative precedence
Rust → wrapping_add / wrapping_sub / wrapping_mul (no infix form in Rust)
Verilog collapse to +/-; *% routes through __mul_noop (RTL wraps by width)
C collapse to +/-/* (C unsigned wraps mod 2^N)
Zig native operators — passed through verbatim (no change)

Checked +/-/* stay infix, so every backend keeps identical overflow-panic semantics.

Verification

  • New cross-backend test test_wrapping_ops_all_backends_1659.
  • Full compiler suite 1495 passed / 0 failed.
  • End-to-end: gen-rust of a *%/+%/-% mixer compiles under rustc; Verilog & C emit 0 literal %-operators.
  • FROZEN_HASH re-sealed (M5).

Supersedes #1660 (the minimal +%-only Rust fix — folded in here).

Closes #1659

🤖 Generated with Claude Code

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>
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

📓 NotebookLM Notebook linked to this PR

This notebook contains session context, decisions, and artifacts for this work.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-08-05 09:31:47 UTC

Summary

Status Count
Total Open PRs 50
PRs with Failing Checks 2
PRs with All Checks Green 48
READY 0
FAILING 2
PENDING 0

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=f70322bce1ac != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

@gHashTag
gHashTag enabled auto-merge August 5, 2026 13:36
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

📓 NotebookLM Notebook linked to this PR

This notebook contains session context, decisions, and artifacts for this work.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-08-05 13:37:13 UTC

Summary

Status Count
Total Open PRs 50
PRs with Failing Checks 0
PRs with All Checks Green 50
READY 0
FAILING 0
PENDING 0

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=f70322bce1ac != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

@gHashTag
gHashTag merged commit deb247e into master Aug 5, 2026
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lang: no wrapping *% / -% / <<% operators — hash mixers can't express wrapping multiply (R7 design)

1 participant