Repository navigation
specs: bench bodies Zig never type-checks (8 specs reject once referenced) #8195
Description
Re-filed from #6268. An attempt claimed that issue on 2026-10-05 and left an empty branch, and a dispatch row that has spent its retry ceiling keeps its issue for good - so no bee could take it again, however much the brief improved. The work below is carried over unchanged.
Problem
Zig analyses a function lazily. A bench body that t27c gen emits is never referenced by a test, so zig test never type-checks it. The bench lane (#6258) referenced every bench with _ = &bench_x; and found that in 8 specs that pass the reference path, Zig rejects the bench body:
value of type 'u32' ignored(a call result dropped as a statement), infpga/boards/arty_a7_integration,fpga/boards/qmtech_a100t_integrationandfpga/testbench/{cts,partition,power,simulator,router}_tb. Example:estimate_latency(...)inbench_cts.unable to resolve comptime valueinisa/ternary_gates(a.{...}tuple indexed with a runtime value).
From the same run: 78 of the 116 former-BenchBlock files fail once their benches are referenced, and fpga/testbench/gf16_accel_tb hangs in test_add_zero.
Goal
Every bench body in specs/ type-checks, and a check keeps it that way.
Original checks (kept for history; the Queen does not run these)
- The 8 specs above compile with every bench referenced (
_ = &bench_x;or an equivalent t27c option). - Either
t27c genemits a reference to each bench, or a CI check compiles the bench bodies. Whichever is chosen is written down in the PR. - The 78-file figure is re-measured and either fixed or listed in a ledger.
Original file list
Spec fixes under specs/, plus t27c's zig backend if the chosen fix is to emit a reference. t27b does not change: it already lowers and compiles each bench body (#6258).
Refs #6063
Queen-runnable restatement (2026-10-05)
The first attempt (branch queen-6268) left no diff against master. Re-measured on master 13e212a by generating each spec, appending test { _ = &bench_x; } for every bench and running zig test --test-no-exec: all 8 specs are still rejected (7 with value of type 'u32' ignored, isa/ternary_gates with unable to resolve comptime value at the bench bodies that are written in Zig syntax - @setEvalBranchQuota, @intCast, for (0..1000)). A spec-only fix is measured to work: writing the dropped call as _ = estimate_latency(...); in cts_tb.t27 removes that error. This restatement covers the spec fixes; the generator option and the CI check from the original goal are hand-written Rust/YAML and are not part of this card.
Boundary
specs/fpga/boards/arty_a7_integration.t27specs/fpga/boards/qmtech_a100t_integration.t27specs/fpga/testbench/cts_tb.t27specs/fpga/testbench/partition_tb.t27specs/fpga/testbench/power_tb.t27specs/fpga/testbench/simulator_tb.t27specs/fpga/testbench/router_tb.t27specs/isa/ternary_gates.t27
User Scenarios & Testing
- Given master, where each listed spec's bench body is rejected by Zig once the bench is referenced, when every dropped call result in a bench is written as
_ = call(...);and theternary_gatesbenches are rewritten in t27 constructs (no@builtins, nofor (0..n), the operand array indexed by a value the language defines), thenzig testaccepts each spec with every bench referenced. - Given the fixed specs, when
t27c test-reportruns them, then their existing tests still pass.
Requirements
- FR-001: The change MUST make every bench body in the 8 listed specs type-check when referenced, by editing the bench bodies only.
- FR-002: The change MUST NOT change test blocks or function bodies, and MUST keep every bench (no deletion of a bench to silence it).
- FR-003: The change MUST NOT add or modify non-t27 hand-written code (specs/policy/own_language.t27);
bootstrap/and.github/are out of scope.
Success Criteria
grep -cE '^ +_ = ' specs/fpga/boards/arty_a7_integration.t27prints at least1grep -cE '^ +_ = ' specs/fpga/boards/qmtech_a100t_integration.t27prints at least1grep -cE '^ +_ = ' specs/fpga/testbench/cts_tb.t27prints at least1grep -cE '^ +_ = ' specs/fpga/testbench/partition_tb.t27prints at least1grep -cE '^ +_ = ' specs/fpga/testbench/power_tb.t27prints at least1grep -cE '^ +_ = ' specs/fpga/testbench/simulator_tb.t27prints at least1grep -cE '^ +_ = ' specs/fpga/testbench/router_tb.t27prints at least1grep -c '@' specs/isa/ternary_gates.t27prints0t27c test-report specs/fpga/testbench/cts_tb.t27 | grep -cE '^ FAIL +0$'prints1t27c parse specs/isa/ternary_gates.t27exits 0 and the spec has at least 2 tests.
The instruments
Every one of these reads and prints; none of them writes. Run them from the repository root, with <spec> replaced by the file in ## Boundary:
.t27 is not Rust and not Zig, and a bee fluent in either writes one by
accident. Measured 2026-09-20: a bee filled eight bodies in
specs/file/watcher.t27 with return Ok(());, Err(FileError::WatcherNotFound)
and for i in 0..watchers.length. The parse ratchet refused the whole file --
Unexpected token in expression: RParen, line 123 -- and a spec that does not
parse generates nothing, so every test it already carried stopped running.
At the top level the parser accepts exactly these eight forms, with an optional
pub, and no others:
const var fn enum struct test invariant bench
There is no trait, no impl, no type X = ..., no generics, no macro. What
a bee reaches for from another language, and what happens:
- Rust's result sugar (
Ok(()),Err(E::V),?) is not a construct here. - Rust macros (
println!,format!,vec!) are not constructs here. - A range loop (
for i in 0..n) is Rust and Zig, not this language. - Zig builtins (
catch unreachable,@intCast,@constCast) are not constructs here. - Cross-module reuse (
use other::fn;) parses and then generates a comment and an unqualified call, so the Zig fails withuse of undeclared identifier(use a::b; generates no import, so no spec can reuse a function from another spec #4298). It does not work yet.
t27c parse <spec> answers in one line whether what you wrote is the language.
Run it before you report, every time.
t27c spec-status <spec>- the compiler's one-word verdict: IMPLEMENTED, PARTIAL, UNWRITTEN, NOPARSE, NOFN. Exit code is 0 whatever it says, so read the word.t27c symbols <spec>- every name the file declares, with its kind. Answers "does this already exist here?" before you add it.t27c outline <spec>- per function: its locals, what it calls, what it returns. The contract you are implementing against.t27c coverage <spec>- which functions have a test and which do not. The issue asks for tests; this is how you check you wrote them.t27c lint <spec>- style and shape warnings. It OVER-REPORTShas no test or invariant: measured 2026-09-20 over 60 specs it printed 677 of those wherecoveragefound 190 untested functions, disagreeing on 59 of the 60 - it warns aboutbit_to_trit_pairinspecs/base/ternary_encoding.t27, whichtest bit_to_trit_pair_zerocalls on line 249. Read it as a hint;coverageis the answer.t27c typecheck <spec>- types, before generation. PrintsTypecheck OK (0 errors, 0 warnings)or the errors.t27c test-report <spec>- builds this spec and runs its own tests, which is what the oracle does.BLOCKEDmeans the generated Zig does not compile, with the error beside it.python3 tools/dupe_scan.py --name <function>- where that function already lives, if it does. 576 of 4021 bodies here are byte-identical copies.
The rest of the toolbelt is in docs/BEE_TOOLBELT.md.
Activity
docs: the coordination entry this branch needs to land
specs: bench bodies type-check once referenced (8 specs) (Closes #8195,…
t27b: a bench's `_ = e;` is a discard, and ternary_gates' benches typ…