Repository navigation
gen-c uses Trit 141 times and declares it zero times: the C backend does not follow "use" #5278
Description
Re-filed from #2764. An attempt claimed that issue on 2026-09-24 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.
t27c corpus puts C last of the four backends — 157 of 559 accepted (24.2%), against Zig 217, rustc 214 and Verilog 378. The largest systematic cause is not a long tail.
The measurement
specs/vsa/ops.t27 opens with
use base::types;
use base::ops;
and Trit is declared in specs/base/types.t27. The generated C:
$ t27c gen-c specs/vsa/ops.t27 | grep -c Trit
141
$ t27c gen-c specs/vsa/ops.t27 | grep -cE '^typedef|^enum'
0
141 uses, zero declarations. The prelude emits only <stdint.h> <stdbool.h> <stddef.h> <assert.h> and nothing from the imported spec. cc reports unknown type name 'Trit' in 12 specs measured across the whole corpus.
What this is not
It is not a missing typedef Trit in the prelude. Trit is not a language built-in — it is declared in a spec, and other specs import it. Adding a typedef would paper over the actual gap and invent a representation the language never fixed.
The gap is that gen-c does not resolve use: it emits a standalone translation unit per spec and never emits, includes, or forward-declares anything the spec imported.
Rust has the same shape, C just fails louder
gen-rust on the same spec emits pub fn bind(a: Vec<Trit>, …) with no Trit in scope either. Zig drops the affected code entirely, so its number does not show the cost. Three backends, three different silences over one missing mechanism.
Why this is worth doing
Every other lever in the Rust column has now been pulled — the ruler (-o /dev/null, #2760), unconditional serde derives (#2760), and Vec<const T> — taking it from a false 0 to 214. C has had none of that, and this is the one cause that is systematic rather than per-spec: the first-error histogram is otherwise a long tail of user types appearing once each.
Effort is days, not minutes: it needs a decision about what an imported declaration becomes in C — a generated header per spec plus #include, or inlined declarations in dependency order — and the same decision then applies to Rust.
Boundary
specs/base/types.t27specs/vsa/ops.t27
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
gHashTag commentedon Oct 3, 2026
Done on master. gen-c and gen-rust now resolve
usethrough bootstrap/src/use_resolve.rs (6928f02, refined in #2831 and #2837), andt27c gen-c specs/vsa/ops.t27emitstypedef enum {...} Trit;with nounknown type name 'Trit'under cc. Corpus-wide that error is down from 12 specs to 6. The 6 left have different causes (an import from the nonexistenttritype-basemodule, a splice fallback in hslm.t27, nousein composition.t27) and would each need their own card.Triage for the review jam, #5776: this card was escalated because it states no acceptance criterion the Queen can read. Reopen if this is wrong.