Skip to content

fix(gen-c): a local nested array is declared as a C matrix (Closes #7441) - #7495

Merged
gHashTag merged 6 commits into
masterfrom
genc-local-nested-array
Oct 8, 2026
Merged

gHashTag merged 6 commits into
masterfrom
genc-local-nested-array

Conversation

@gHashTag

@gHashTag gHashTag commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Closes #7441
Part of #5980

What was wrong

gen-c declared a local nested fixed array with a t27 type left inside the C text: var m: [16][16]u8 became [16]u8 m[16], which no C compiler accepts. specs/depin/prove.t27 and specs/vsa/similarity_search.t27 hit it, and the self-host needs it.

The fix

bootstrap/src/compiler.rs (+24/-2): every inner fixed dimension moves from the element type to the declarator, the same way a struct field (c_array_field) and a module-level array are already declared: uint8_t m[16][16]. A slice, sentinel or inferred inner dimension stops the peel and keeps the old path.

Regression test

c_declares_a_local_nested_array_as_a_matrix in bootstrap/tests/backend_behaviour.rs compiles three functions with cc and runs them: a [16][16]u8, a [2][K][4]i64 with a named constant dimension, and an initialized [2][2]u8. It expects 4 8 32.

Run on the lab both ways:

  • old compiler (master t27c): the C does not compile, so the test fails;
  • new compiler: passes.

Reseals

Only gen_hash_c moves:

  • .trinity/seals/prove.json and depin_depin.prove.json: 1fe0bdf2 -> 832862c5
  • .trinity/seals/SimilaritySearch.json, VSASimilaritySearch.json and vsa_VSASimilaritySearch.json: fa36bdca -> 9b62b16e

Lab runs

Foreign-line budget (#7371)

Master's check_budget() passes on this diff: compiler.rs +24/-2, backend_behaviour.rs +16. FROZEN_HASH and the seals do not count.

🤖 Generated with Claude Code

gHashTag and others added 3 commits October 7, 2026 17:02
)

A local `[16][16]u8` kept its inner `[16]` in the element type and reached C
as `[16]u8 m[16]`. Every inner fixed dimension now moves to the declarator,
`uint8_t m[16][16]`, as a module-level array and a struct field already do.
A slice or sentinel dimension stops the peel. The test in
backend_behaviour.rs compiles and runs a 2-D, a 3-D with a named size, and an
initialized local. Part of #5980.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…l matrix declarator

Only gen_hash_c moves: the local declarators become `T m[A][B]`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rray

# Conflicts:
#	bootstrap/stage0/FROZEN_HASH
#	bootstrap/tests/backend_behaviour.rs
@gHashTag gHashTag added the owner-approved-foreign Owner-approved exception to the only-t27 rule: hand-written foreign code allowed in this PR label Oct 7, 2026
@gHashTag
gHashTag enabled auto-merge (squash) October 7, 2026 11:43
@gHashTag

gHashTag commented Oct 7, 2026

Copy link
Copy Markdown
Owner Author

Lab run on the merged head dad468e: https://t27c-lab-production.up.railway.app/runs/dad468e0574f23b35cc39537dca5bf7b51cd7a14.json. frozen-hash, build, suite (RATCHET CLEAN), seal-currency, seal-coverage (1489 seals, 6 stale, the same as master), specs-generate and misread are green. The one red, the lean gate (ml_transformer_multi_head_attention: Rust=true, Lean theorem=false), is also red on master b94f486: https://t27c-lab-production.up.railway.app/runs/b94f48659d29bbdbfad76669c5277283a8c11672.json

This was referenced Oct 7, 2026
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-07 12:51:15 UTC

Summary

Status Count
Total Open PRs 50
PRs with Failing Checks 46
PRs with All Checks Green 4
READY 1
FAILING 46
PENDING 0
NO CHECKS YET 0

These columns do not partition: 1 + 46 + 0 + 0 = 47, and there are 50 open PRs. A PR is being counted twice or not at all.

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=73a4ac69348c != 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).

#7331 landed and changed bootstrap/src/compiler.rs; compiler.rs merged
cleanly (both sides' gen-c changes kept), and the derived files that
conflicted are regenerated, not merged by hand:

- bootstrap/stage0/FROZEN_HASH: the sha256 of the merged compiler.rs,
  3c0ade9e73e425d5...
- The three similarity_search seals (SimilaritySearch,
  VSASimilaritySearch, vsa_VSASimilaritySearch): resealed with
  `t27c seal --save`, t27c built from this tree on the t27c lab, zig 0.16
  on PATH (8/8 tests pass). `check_seal_currency.py --stale-specs` then
  names only html, xml and terminal, master's ledgered debt.
- check_seal_currency: exit 0; check_seal_coverage: OK (1641 seals, 1520
  hold, 121 known-broken, as on the baseline); `tri seals twins`:
  1636 / 548 / 31 disagree, the same as master eda79f0;
  backend_behaviour 24/24 (c_declares_a_local_nested_array_as_a_matrix
  ok), core_selfhost 1/1. gen-c of t27core.t27 is unchanged (the DDC
  pins of master and of #7436 both still hold).

Closes #7441

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gHashTag
gHashTag disabled auto-merge October 8, 2026 17:56
@gHashTag
gHashTag changed the base branch from master to shep-tmp-base-7495 October 8, 2026 17:56
@gHashTag
gHashTag changed the base branch from shep-tmp-base-7495 to master October 8, 2026 17:56
@gHashTag gHashTag added ci and removed ci labels Oct 8, 2026
@gHashTag

gHashTag commented Oct 8, 2026

Copy link
Copy Markdown
Owner Author

Merge shepherd: #7331 landed, and this PR then conflicted, so I merged master eda79f0 in from master's side (9360cc3, a fast-forward). compiler.rs merged cleanly, keeping both sides' gen-c changes. The derived files were regenerated. FROZEN_HASH is the sha256 of the merged compiler.rs, 3c0ade9e73e425d5... The three similarity_search seals were resealed with t27c seal --save, using t27c built from the merged tree on the t27c lab (8/8 tests pass). After that, check_seal_currency.py --stale-specs names only html, xml and terminal, master's ledgered debt. Results on the merged tree: check_seal_currency exits 0; check_seal_coverage is OK (1641 seals, 1520 hold, 121 known-broken); tri seals twins gives 1636 / 548 / 31 disagree, the same as master; backend_behaviour 24/24, including c_declares_a_local_nested_array_as_a_matrix; core_selfhost 1/1. gen-c of t27core.t27 does not move, so the DDC pins of master and of #7436 still hold. Foreign-line budget: master's check_budget() allows it with compiler.rs +24 and backend_behaviour.rs +16, and check_all() gives exit 0. The stale base.sha was cleared (#7489): auto-merge was off, the base was flipped to a temporary branch and back to master and checked, the ci label was re-added, the temporary branch was deleted, and then auto-merge was turned back on.

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-08 18:34:18 UTC

Summary

Status Count
Total Open PRs 50
PRs with Failing Checks 45
PRs with All Checks Green 5
READY 1
FAILING 45
PENDING 0
NO CHECKS YET 0

These columns do not partition: 1 + 45 + 0 + 0 = 46, and there are 50 open PRs. A PR is being counted twice or not at all.

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=3c0ade9e73e4 != 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 188da7e into master Oct 8, 2026
42 of 47 checks passed
gHashTag added a commit that referenced this pull request Oct 8, 2026
…loses #7929) (#7931)

Part of #5980 (P1: `**` with a real meaning, numeric literal forms).

The self-hosted core accepts a local `var` array as gen-c lowers it, a
module array without `static`: a repeat (a GNU range, `{0}` for zero), a
list, or a row list (a C matrix, #7495), in a function or a test.

It refuses what gen-c lowers with loss:
- E_NAME: a local array named like a module name, a parameter or another
  local of its function (C's shadowing array, which Zig refuses);
- E_ARRAY: a local array read outside its block, a dimension or count
  that is not a number or a number-valued const (an initialized C VLA),
  and a repeat count that differs from the dimension, module arrays
  included (C zeros where Zig refuses the type).

#7318 is fixed, so the `_` separators in a dimension and in a negated
literal const are dropped as gen-c drops them; the three refusals move
to accept/separator_dimensions.t27. Numeric `a ** b` stays refused
(E_SYNTAX), now pinned by two fixtures on #7427.

t27core_ddc.t27 restates the new module vars and is repinned: S 84235,
E 78795 bytes.

Co-authored-by: Claude <claude@anthropic.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci owner-approved-foreign Owner-approved exception to the only-t27 rule: hand-written foreign code allowed in this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

t27c gen-c: local nested array declared as [16]u8 m[16]

2 participants