Skip to content

t27core: nested arrays and list initializers, byte-identical to gen-c (Closes #7361) - #7374

Merged
gHashTag merged 2 commits into
masterfrom
self-host-p1-slice3
Oct 7, 2026
Merged

gHashTag merged 2 commits into
masterfrom
self-host-p1-slice3

Conversation

@gHashTag

@gHashTag gHashTag commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Closes #7361
Part of #5980

P1 slice 3 of the self-hosted core: nested arrays and list initializers. defer stays refused, because gen-c drops the deferred call (#7352).

What the core learns

  • A 1-D array global takes a list initializer [_]T{ e, ... } with a trailing comma allowed. The elements are any expressions in the subset: names, constants, _-separated and hex numbers, operators.
  • A 2-D global [N][M]T takes rows: [_][M]T{ [_]T{ e, ... }, ... }. The core writes T a[N][M] = { { e, ... }, ... };, which is the bytes t27c gen-c writes.
  • a[i][j] reads, stores and op= work in functions and in tests.

What the core refuses

Fixture Code Why
e9_nested_repeat, e9_nested_repeated_row E_ARRAY gen-c nests C comments, or zeroes the repeated rows (#7353)
e9_list_too_short, e9_row_count_short E_ARRAY gen-c pads with zeros; Zig refuses
e9_list_too_long, e9_row_too_long E_ARRAY gen-c hands C the excess, which C drops
e9_named_dimension_list E_ARRAY the item count cannot be checked against a name
e9_separator_in_inner_dimension E_ARRAY gen-c writes a[1][1_0] (#7318)
e9_inner_dimension_mismatch, e9_row_type_mismatch E_ARRAY the row type disagrees with the array
e9_row_used_as_value, e9_nested_array_as_value E_ARRAY C reads a row where a scalar goes
e3_three_dimensions E_TYPE only one or two dimensions are in the subset
e2_defer_call E_SYNTAX gen-c writes defer as a comment, so the call never runs (#7352)

Size

The core is at its source buffer. SRC_MAX is 65536, which is t27b's repeat-initializer cap. To fit, node-array reads go through seven one-line accessors (na(n) for nd_a[n as usize], and so on), two dead text functions are removed, and comments are tightened. S is 65341 bytes. The next slice needs the cap raised, or the buffers split.

Other changes

  • No Rust or compiler.rs change, so no foreign label is needed. for and switch are untouched.
  • t27core_ddc.t27 is repinned:
    • S is 65341 bytes, sha256 41a73cd5...;
    • E is 62437 bytes, sha256 4e6424a4....
      Decoding its data reproduces both files byte for byte.

Checked on the t27c lab

  • The core's 16 tests pass, two of them new.
  • Fixpoint: core(core.t27) == gen-c(core.t27).
  • accept/nested_arrays.t27 is byte-identical with gen-c, and its test binary (-std=c99 -DT27_TEST_MAIN) exits 0.
  • All 29 refusal fixtures give their codes.
  • The corpus differential accepts 61 files (previously 60), with no mismatch.
  • cargo test --release -p t27c --test core_selfhost passes, and so do specs-parse and specs-generate.

🤖 Generated with Claude Code

…Closes #7361)

P1 slice 3 of the self-hosted core (Part of #5980).

- A 1-D array global takes a list `[_]T{ e, ... }`, and a 2-D global
  `[N][M]T` takes rows `[_][M]T{ [_]T{ e, ... }, ... }`; the core writes
  `T a[N][M] = { { e, ... }, ... };` as gen-c does. a[i][j] reads, stores
  and op= work in functions and tests.
- Refused with E_ARRAY, since gen-c lowers them with loss or Zig refuses
  them: the nested repeat and a repeated row (#7353), a list or row whose
  item count is not its dimension, a named dimension with a list, a `_`
  in an inner dimension, a mismatched inner dimension or row type, a row
  or whole array used as a scalar. Three dimensions stay refused.
- `defer` stays refused: gen-c writes it as a comment and the call never
  runs (#7352). Fixture e2_defer_call.
- The core sits at its 64 KiB source buffer (t27b's repeat cap). Node
  array reads go through accessors and comments are tightened to fit:
  S is 65341 bytes.
- t27core_ddc.t27 repinned to S (65341 bytes) and E (62437 bytes).

Checked on the t27c lab: 16 core tests pass, fixpoint holds, the three
accept fixtures are byte-identical and run, 29 refusals give their codes,
corpus differential 61 files with no mismatch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-07 08:41:45 UTC

Summary

Status Count
Total Open PRs 50
PRs with Failing Checks 42
PRs with All Checks Green 8
READY 2
FAILING 42
PENDING 0
NO CHECKS YET 0

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

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=1aa228450491 != 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 e54d02d into master Oct 7, 2026
28 of 33 checks passed
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-07 08:51:19 UTC

Summary

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

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

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=1aa228450491 != 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 added a commit that referenced this pull request Oct 7, 2026
…counter (Refs #7307)

After the second master merge (#7374, #7360, #7365), these three specs'
gen-c differs under this branch's compiler only by `for (int ` ->
`for (size_t `, so the Railway t27c lab resealed them (6 files with twins).

Lab check on the merge tree f4edb20 vs master fe1c866:
- gen-c corpus: 132 of 1538 specs change, all counter-type only; no exit-code change
- seal-currency stale list after reseal = master's 13 (all ledgered in tools/seal_baseline.txt)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gHashTag added a commit that referenced this pull request Oct 8, 2026
…se (Closes #7307, Closes #7308) (#7331)

* fix(t27c gen-c): size_t range counter, refuse an integer switch without else (Closes #7307, Closes #7308)

#7307: gen-c declared a range `for` counter as `int`. A range capture is a
`usize`, so the counter is now `size_t`; past INT_MAX the old counter
overflowed and a start bound above INT_MAX ran the loop zero times.

#7308: an integer switch with no `else` (or `_`) arm compiled to a C
conditional chain ending in `: 0`, so an unmatched value yielded 0 where
Zig refuses the program. compile_c now refuses it with
"non-exhaustive switch". Enum switches are unchanged.

Repros: specs/compiler/genc_for_counter.t27,
specs/compiler/genc_switch_exhaustive.t27, driven by
bootstrap/tests/genc_for_counter.rs and genc_switch_exhaustive.rs.

Part of #5980

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

* seals: reseal the 99 specs whose gen-c moved from `int` to `size_t` counters (Refs #7307)

Every changed gen_hash_c was checked on the t27c lab: for each spec, the
master compiler's C with `for (int ` replaced by `for (size_t ` is
byte-identical to the fixed compiler's C. No zig, rust or verilog hash
moved. specs/isa/ternary_shift.t27 was already sealed with --force and
the same two failing tests; it is resealed the same way.

The inclusive-range test expects `(n + 1)`, which is how gen-c renders
the lowered bound.

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

* seals: reseal the 8 specs the merge left stale under the size_t counter (Refs #7307)

The master merge took master's side for 18 conflicting seal files. Under
this branch's compiler, 8 of those specs (16 files with their twins)
produce different gen-c, so the Railway t27c lab resealed them:
constants, phi_split_optimality, gf8, gf12, gf20, gf24, gf32, phi_ratio.
TriTopological's master seal already matches.

Lab check on the merge tree (6ae177d) vs master e45ba56:
- gen-c corpus: 132 of 1527 specs change, all only `for (int ` -> `for (size_t `; no exit-code change
- seal-currency stale list after reseal = master's 18, identical

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

* seals: reseal knowledge_graph, graph_bfs, prims_mst under the size_t counter (Refs #7307)

After the second master merge (#7374, #7360, #7365), these three specs'
gen-c differs under this branch's compiler only by `for (int ` ->
`for (size_t `, so the Railway t27c lab resealed them (6 files with twins).

Lab check on the merge tree f4edb20 vs master fe1c866:
- gen-c corpus: 132 of 1538 specs change, all counter-type only; no exit-code change
- seal-currency stale list after reseal = master's 13 (all ledgered in tools/seal_baseline.txt)

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

* t27c gen-c: fit #7331 into the foreign-line budget; its tests become t27 data

Owner rule #7371 caps hand-written foreign additions at 40 lines per file
and 80 per PR. This PR was +64 in compiler.rs and +237 in two new Rust
integration tests, so the own-language budget denied it.

- compiler.rs: same two fixes, +39. The size_t comments shrink to one
  line, and the #7308 check builds one label list instead of two. The
  behaviour is unchanged: an integer switch (number, negative or char
  label) with no `else` or `_` arm is refused, and enum-literal switches
  are left alone.
- The two Rust test files and their specs/compiler repro specs are gone.
  The same checks are now .t27 data run by the existing core_selfhost
  harness: fixtures/core_selfhost/genc/ is built by gen-c and its tests
  are run (for_counter: counts past INT_MAX; switch_exhaustive: else, `_`,
  enum switches), and fixtures/core_selfhost/both_refuse/ joins
  BOTH_REFUSE (the issue repro, negative and char labels). The harness
  hook is a few lines in core_selfhost.rs.
- The foreign-exceptions entries for the deleted tests are removed.

Refs #7307, #7308

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

* fixtures(core_selfhost/genc): build no `_` arm; gen-c writes `(x == _)` for it

The runnable switch fixture had a `_ =>` arm. gen-c still lowers that arm
to `(x == _)`, which C cannot compile -- the known defect owned by the
gen-c defects lane, out of scope here. The old Rust test only checked
that gen-c accepts the arm; the corpus spec
specs/demos/jones_topology_decision_gate.t27 keeps that covered, since
its three numeric switches end in `_ =>` and still generate.

Refs #7308

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

* seals: reseal the 10 specs the third master merge left stale under the size_t counter (Refs #7307)

After merging master (#7535, #7537), these specs' gen-c differs under this
branch's compiler only by `for (int ` -> `for (size_t ` (0 other changed
lines each), so the Railway t27c lab resealed them (20 files with twins):
automation/bot-topic-tabs, base/types, graph/knowledge_graph,
math/phi_universal_attractor, runtime/execute, runtime/instance,
sync/index, sync/schema, tri/collections/bitvector, vsa/vsa_core.

Lab check on the merge tree:
- FROZEN_HASH matches the merged compiler.rs; cargo build --release -p t27c passes
- check_seal_currency.py: 0 stale gen hashes, 6 ledgered (same as master)
- check_seal_coverage.py: OK, 1496 seals, 121 known-broken all ledgered
- cargo test --release -p t27c --test core_selfhost: 1 passed (genc and both_refuse fixtures)

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Claude <claude@anthropic.com>
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.

Self-host P1 slice 3: nested arrays and list initializers; defer stays refused

1 participant