You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(rust-backend): array types, index casts and boolean coercion (#1573)
* fix(rust-backend): array types, index casts and boolean coercion
The Rust backend emitted code that does not compile. In gHashTag/tri-net
this produced 32 compile errors across 9 generated modules and has kept
CI red since 2026-07-23. After this change that repository's library
builds clean and its 101 library tests pass.
Three defects, all in RustCodegen:
1. Fixed-size array types were dropped. `t27_type_to_rust` handled the
`[]T` and `[N]T` forms but not `[T; N]`, so `[u32; MAX_FLOWS]` became
`Vec<>` (26 x E0107 "missing generics for struct Vec"). Now emitted as
`[u32; MAX_FLOWS as usize]`; the `as usize` is required because named
constants are emitted as u32 while Rust array lengths are usize.
2. Indices were not cast. t27 indices are u32, Rust requires usize, so
`flows[i]` did not compile. Non-literal indices now emit
`flows[(i) as usize]`; literals are left alone.
3. t27 treats comparisons as integers, Rust does not, and the backend
never reconciled the two. `return (a >= b);` from a function returning
u32, and `if (!f(x))` where f returns u32, both failed. Added a
syntactic classifier (expr_is_bool) plus two emission helpers:
conditions get `!= 0` when the expression is integer-valued, integer
positions get `as u32` when the expression is boolean, and `!x` on an
integer emits `((x) == 0)` rather than Rust's bitwise negation.
The classifier is type-aware where it has to be: a recursive pre-pass
collects functions declared `-> bool`, and parameters and locals
declared `bool` are collected per function, so a call to a
bool-returning function is not given a spurious `!= 0`.
FROZEN_HASH reseal: compiler.rs changed, so the M5 seal was recomputed
per FROZEN.md section 5. This PR carries the mechanical reseal only; the
governance part of the ceremony (GOLD-RING intent, Architect approval) is
for the maintainer.
docs/.legacy-non-english-docs: three already-committed files tripped the
language gate and blocked every build before the backend could even be
compiled. They are grandfathered here through the documented mechanism,
not edited.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* docs(NOW): record the gen-rust backend fix (Closes#1574)
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: Dmitrii Vasilev <admin@t27.ai>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/NOW.md
+23Lines changed: 23 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,26 @@
1
+
# NOW — Rust backend type fixes (2026-07-31)
2
+
3
+
Last updated: 2026-07-31
4
+
5
+
## gen-rust: array types, index casts, boolean coercion (Closes #1574)
6
+
7
+
- Branch: `fix/rust-backend-types`
8
+
- Issue: #1574
9
+
- The Rust backend emitted code that does not compile; downstream tri-net had 32 errors and red CI since 2026-07-23.
10
+
11
+
### Что легло
12
+
-`t27_type_to_rust` — форма `[T; N]` больше не схлопывается в `Vec<>`; эмитится `[T; N as usize]`.
13
+
-`ExprIndex` — нелитеральный индекс приводится к `usize`.
14
+
- Целые и булевы согласованы: классификатор `expr_is_bool`, `!= 0` в условии, `as u32` в целочисленной позиции, `((x) == 0)` вместо побитового `!`.
15
+
- Рекурсивный предпроход собирает функции `-> bool`, плюс `bool`-параметры и локальные, чтобы вызов булевой функции не получал лишний `!= 0`.
16
+
17
+
### Границы честности (BINDING)
18
+
- Проверено downstream: библиотека tri-net собирается, 101 тест проходит.
19
+
- FROZEN_HASH переподписан механически; governance-часть церемонии M5 (GOLD-RING, одобрение Архитектора) не выполнялась.
20
+
-`fpga-synthesis` падает на SystemVerilog-касте `8'(...)` в Verilog-бэкенде — воспроизведено на немодифицированном master, к этой работе отношения не имеет.
21
+
22
+
---
23
+
1
24
# NOW — conformance instance-пакеты + Lean φ-скелет (2026-07-29)
0 commit comments