Skip to content

feat(codegen): gen-zig tuple lowering (return type + literal + destructuring) - #1725

Merged
gHashTag merged 1 commit into
masterfrom
feat/tuple-zig
Aug 5, 2026
Merged

gHashTag merged 1 commit into
masterfrom
feat/tuple-zig

Conversation

@gHashTag

@gHashTag gHashTag commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Part 4 of the tuple-support workstream (#1702). Parser + gen-rust (#1710, #1716) + gen-verilog (#1718) already landed; this is gen-zig.

Closes #1724.

Before (master) — invalid Zig

pub fn dm(a: u32, b: u32) (u32, u32) { return ; }
pub fn use_it(a: u32, b: u32) u32 { const  = dm(a, b); return s + d; }

Change (3 touchpoints, additive)

  1. gen_fn_decl — tuple return type (T, U) → Zig anonymous tuple struct struct { T, U }.
  2. gen_expr ExprTuple — tuple literal → .{ e0, e1 }.
  3. gen_stmt StmtLocal — let (s, d) = call() → const s, const d = call();.

After

pub fn dm(a: u32, b: u32) struct { u32, u32 } { return .{ a + b, a - b }; }
pub fn use_it(a: u32, b: u32) u32 { const s, const d = dm(a, b); return s + d; }

Verification

  • Emitted Zig compiles under Zig 0.15.2 (zig build-obj) and comptime-evaluates: use_it(5, 3) == 10, dm(7, 2) == (9, 5).
  • New unit test test_tuple_literal_and_destructuring_zig; full unit suite 1499/0.
  • FROZEN_HASH re-sealed; docs/NOW.md prepended (no shrink).

Pre-existing unrelated failures bitnet_top::{top_busy_from_current_layer_or_layer_start, top_mem_outputs_tied_off} reproduced on clean origin/master — not introduced here (they were previously masked because bitnet_pipeline aborted the run first). Will be tracked/fixed separately.

gen-c is the last remaining backend on #1702.

🤖 Generated with Claude Code

…cturing)

Part 4 of tuple support (#1702), the Zig backend.

- gen_fn_decl: tuple return type (T, U) -> Zig struct { T, U }
- gen_expr: ExprTuple -> Zig anonymous tuple value .{ e0, e1 }
- gen_stmt: let (s, d) = call() -> const s, const d = call();

Emitted Zig compiles under Zig 0.15.2 (zig build-obj) and comptime-evaluates:
use_it(5,3)=10, dm(7,2)=(9,5). New test test_tuple_literal_and_destructuring_zig;
full suite 1499/0. FROZEN_HASH re-sealed. gen-c remains (#1702).

Closes #1724

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 15:58:52 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)=72259bcd33d7 != 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).

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.

codegen: gen-zig tuple lowering (tuple return type + literal + let-destructuring)

1 participant