rpg_source_forms.zig, rpg_source_render_emit.zig: the trailer for declarations that do not fit says how many lines are missing #798

Manually merged
binjovi-bot merged 1 commit from ldfit into trunk 2026-11-13 23:13:01 +00:00
Owner

rpg_source_forms.zig, rpg_source_render_emit.zig: the trailer for declarations that do not fit says how many lines are missing

The compiler numbers a statement by its source line, so a program whose declarations need more lines than the lines
before its first statement shifts every statement after them, and it can never match. The emit already says so in a
trailer. The trailer now also says how many lines the declarations lack:

before:  // SOURCERER-FAIL declarations do not fit before source line 7: later statement numbers move
after:   // SOURCERER-FAIL declarations do not fit before source line 7: 2 lines missing

Layout.missing is the sum of the rises of the displacement of numbered lines (Layout.push): the lines by which text
that has no number pushed a numbered line below its number, counted again only where the push grows; a numbered line that
lands on its number ends the push. It is the shortfall under the rule the emitter applies now (the declarations of a scope
go on the lines before the first statement of that scope). The text keeps the prefix declarations do not fit before source line N that rt-stmt-diff.sh, agree.awk and emit-families.awk read. The tail "later statement numbers move" is
gone: with the count the line is 78 to 82 characters (the old one was 92 to 94), and clip cuts a trailer at 100. Both trailer sites (render and
renderColumns) use one helper. Nothing else in any emit changes.

No placement rule is shipped. No public compiled source puts a declaration after an executable statement, so the objects
do not say whether the compiler accepts it or whether it changes the object (see "Why no placement rule yet").

Measure (2026-11-13, v0.1.513, every public emit with the trailer)

Trailer counts before and after this change: Async 6, scout2 1, committed twins 28 (the same programs; the committed
twin ldsv-asyncprom is the Async program asyncprom, so 34 distinct programs, 35 emits). Of the 19 scout2 captures one
carries the trailer (barrettotte-vscode-ibmi-languages-1), not 7. The brief's 7 may be Async 6 plus this 1; that is a guess.

Where the source put its declarations: in none of the 35 programs after an executable statement of the same scope. The
fixed-form twins cannot (D before C). The 7 free-form captures: every local declaration directly after end-pi, every global
before the first dcl-proc. A search for a dcl-s, dcl-c, dcl-ds or dcl-pr that follows an executable statement of its
scope, or a global that follows a dcl-proc or a module-level statement (/IF DEFINED blocks evaluated, continuation lines
skipped, on-exit counted as code) finds none in 753 committed free-form sources (the rpg-corpus files hold several programs
each, so they are left out), in the 25 captures, and in the 8 free-form dev5 sources. No compiled object decides the question.

The Async emits (the lines are source lines; need = declaration and interface lines of the emit, lead = the lines the
current rule has (before the first statement of each scope), free = all free lines of the scopes, contiguous or not, so
need > free proves that no placement fits):

emit scopes scopes over lines missing need lead free
l10-async-asyncage 51 15 50 323 805 832
l10-async-asyncdemo 52 15 50 332 828 864
l10-async-asyncbg 52 15 50 326 861 891
l10-async-asynccncl 53 15 50 333 834 866
l10-async-asyncprom 51 16 56 337 837 874
l10-async-asynctime 54 15 50 340 834 866

In each program 15 scopes (asyncprom 16) are over, and none of them packs in order into the free runs of its procedure
(a block of lines is one run). In 13 of them the whole procedure, blank lines after the first statement included, has fewer
free lines than the emit has declaration lines: 44 lines short in all even if every free line were usable. Gaps cannot
fix a program of this kind. The cause is the size of the declarations: asyncage
has 38 local dcl-ds ... likeds(task_t) based(p) lines in the source, one each. The emit recovers 18 of them as full
structures of 100 lines in all (18 dcl-ds, 35 filler lines Gn char(k), 29 subfield lines, 18 end-ds;), where the
source spends 18 lines. (likeds of the template and a pos() subfield in place of a filler would shorten them; neither is
in this change, and pos() is not proved.)

The scout2 emit: l10-barrettotte-vscode-ibmi-languages-1 is a different defect. The on-exit section is written as a
procedure _QRNI_ON_EXIT_MAIN with dcl-pi / one failing parameter / end-pi (3 lines) where the source has the line
on-exit; (line 49) and no interface, so *inlr = *on; (source line 50) lands on line 53. It misses 3 lines. Twins whose
on-exit is recognized write on-exit; (e.g. P700F32C9S).

The 28 committed twins (rows with n/m are programs whose statement numbers are not source lines because the compiler
numbers the generated I/O lines, so lead and free are not computed):

twin (src/testdata/savf/) first line moved lines missing need lead free failure lines incl. the trailer
SC-ILE/EXPERIMENTS/l3b-ds-const 10 1 10 9 9 1
SC-ILE/EXPERIMENTS/lv-pds-pi-ds 12 1 12 11 11 1
SC-ILE/ACCESS 18 1 17 16 16 7
SC-ILE/OPS/ws-fixed-stripped 3 1 n/m n/m n/m 1
SC-ILE/EXPERIMENTS/r5x-cycle-print 4 1 4 3 5 11
SC-ILE/OPS/fixed-exsr-stripped 5 1 n/m n/m n/m 1
SC-ILE/EXPERIMENTS/lsel-for-arr-if-if 43 2 33 49 49 14
SC-ILE/EXPERIMENTS/packed-add-held 5 2 8 10 10 1
SC-ILE/EXPERIMENTS/packed-compose-held 5 2 8 15 15 2
SC-ILE/EXPERIMENTS/lv-af-qual, -evalh, -evalr, -dech 7 2 8 6 8 1
SC-ILE/EXPERIMENTS/lv-af-zadd-packed, -mult-zoned, -mult-f1, -mult-f2, -add-zoned 7 2 8 6 6 1
SC-ILE/OPS/subst-stripped 7 2 8 6 6 2
SC-ILE/FLOW/fx-held-stripped 1 3 3 0 0 11
SC-ILE/FLOW/fx-held2-stripped 1 3 3 0 0 12
SC-ILE/EXPERIMENTS/lr1-ec-loop-next 10 3 12 9 9 1
SC-CONSTRUCT/TRPG3 4 3 64 71 71 15
SC-ILE/EXPERIMENTS/l3b-subst-const 6 3 8 5 5 2
SC-ILE/CALLS/pc-call-stripped 4 4 7 3 7 2
SC-ILE/EXPERIMENTS/l3b-elem-const 6 4 9 5 5 1
SC-ILE/EXPERIMENTS/init-auto-char-heldout 11 5 7 6 6 3
SC-ILE/EXPERIMENTS/ldsv-asyncprom 523 56 337 837 874 305

(need counts the **FREE line, ctl-opt, file declarations and the interface; the statement numbers of the
two programs marked n/m (ws-fixed, fixed-exsr) are not lines: the first calculation of fixed-exsr is statement 9 on
source line 5, because the compiler numbers the lines it generates for the file. fx-held and fx-held2 have a
calculation on line 1, so no line is free before it.) 16 of the 28 have no failure line
except the trailer: l3b-ds-const, lv-pds-pi-ds, packed-add-held, the nine lv-af-*, lr1-ec-loop-next, l3b-elem-const,
ws-fixed and fixed-exsr; so these 16 are the programs that a fit would turn into candidates for a host round trip. None
of the 28 is match in the newest matrix snapshot (base-v0.1.513.ndjson: 25 different, 3 failed).

What the 16 need: a fixed-form source spends one line on H, each F, each D and the subfields of a structure; the
free-form emit spends the same lines plus **FREE and an end-ds; for each structure, and has no free line in the source
to take them (lv-af-evalh: six source lines before the first statement, eight emitted; the two free lines at 8 and 10
are /FREE and /END-FREE, one line each, and the four-line dcl-ds is one block). No fit is possible by placement.

Why no placement rule yet

Placing a declaration after an executable statement is accepted or refused by the compiler, and the objects do not say
which: no public compiled program does it (search above), so a rule would be a guess. Wrong text without a failure line is
worse than a refusal, and a refused compile turns a program with a trailer into one that fails to build. The measure above
shows how little the rule could win: even if the compiler accepted every placement, 32 of the 35 emits have a scope whose
declaration blocks do not pack in order into its free runs (a block is one run), so no placement fits them. The other
three are r5x-cycle-print (11 failure lines) and fixed-exsr and ws-fixed, whose statement numbers are not lines (not
computed) and whose sources have no blank or comment line, so there is no free line to place anything on. The four
lv-af-* twins with free = need show the limit: the free runs are lines 1 to 6, 8 and 10, and the structure is one
block of 4 lines. Packing two statements on one line is closed too until it is measured: docs/DUMP.md records RNF5508
for two statements on a line, and the matrix has the three twins whose emit has chain ...; *in90 = ... on one line
(fk-fixed, fk-fixed2, fk-multifix) as failed.

~/data/sourcerer-loop/requests/ldfit/place/ (manifest, 24 cases, README) is the battery: every variant is the base of
its family with one declaration moved to a line that the base keeps blank, so every statement stays on its line.
Cycle program (M, 8 cases): dcl-s, dcl-c, a four-line dcl-ds and a four-line dcl-pr between two calculations,
dcl-s after the first use (refusal expected), dcl-s after the last calculation, two declarations swapped. Procedure
(P, 7 cases): the same kinds local, a local static. Global between two procedures, before and after the using one
(G, 4 cases). The same procedure cases with option(*srcstmt) (S, 2 cases). Statements on one line (L, 3 cases:
two dcl-s, ctl-opt and dcl-s, a whole dcl-ds). The README says how to read each answer: the compile result, the
operations and statement numbers against the base, the symbol list, the static initialization order. The manifest lists
the cases that must compile first (the four bases and the swap), then the unknowns, then the three l-* cases (refusal
expected, RNF5508), then the three that name a field before its declaration (refusal certain). The batch runner stops at
the first refused compile, so the README says how to rerun the rest into a fresh destination.

Who reads the trailer

rt-stmt-diff.sh (pairs by order when the emit holds declarations do not fit before source line), agree.awk
(declarations do not fit) and emit-families.awk (do not fit before) match a prefix that the new text keeps.
reason-audit.sh takes the first failure line that names statement N: the old trailer ended statement numbers move
(no digits) and the new one has no statement, so for the 16 twins whose only failure is the trailer it finds no
failure line either way. The fixture of tests/rt-stmt-diff.sh has its own text. The header comments of
rt-stmt-diff.sh and agree-twins.sh still quote the old tail; they are in sean/sourcerer-loop, not here.

Proof

  • src/rpg_decl_fit_test.zig (registered in src/root.zig): lv-af-evalh reads 7: 2 lines missing (red before:
    Layout had no count), fk-subp has no trailer and its statements stay on their lines, and Layout counts the rises of
    the displacement and not the lines of the displacement itself (5 declaration lines before line 4: 3 missing; the next
    statement stays 3 below its line: still 3; a line on its number ends it; a second scope short by 2: 5).
  • emit-all.sh with the base binary (v0.1.513) and with this branch, on the 826 emitted twins: a cmp of every file
    finds 28 changed (the 28 above), and diff of each shows only the lines with declarations do not fit. The summary
    line is equal (failures 928, emitted 8422, clean 593). The 854 receipts are equal at statements, emitted,
    failures, placeholders, form_counts, the number of lines and the form of each line, so no form moves.
    capture-emit-diff.sh over the 25 public captures with the branch binary of this ship: 25 cases, 7 changed (6 Async,
    barrettotte), each by its trailer line only, statements, emitted and failures equal in all 25, and no head emit without a
    failure line. emit-bytes-diff.sh exits 1 by design and prints the first 20 lines of each diff: the trailer line of
    P92F0A341S, PABC59092S, PD55A2B53S and P892E45BCS, and rows of the forms projection that differ in text_sha256
    only (form_counts, lines, statements, emitted and failures are equal in every row it printed). None of the 28 is
    match in the matrix.
  • The count matches the shortfall computed outside the emitter (statement positions of the old emit): asyncage 50,
    asyncprom 56, barrettotte 3, and 26 of the 28 twins agree to the line. The two that differ, fixed-exsr and ws-fixed
    (the script says 0, the emitter 1), have statement numbers that are not lines.
  • ship.sh: census 645 / 0 regressions, golden, legend current, emit worse empty, twins and allgroups regressions
    empty, unit, full check.

Gate

diff -r -x emit.ndjson -x *.receipt.json /Users/someara/data/sourcerer-loop/runs/emitbytes.zcb3m6/base-emit/240-PD55A2B53S.rpgle /Users/someara/data/sourcerer-loop/runs/emitbytes.zcb3m6/head-emit/240-PD55A2B53S.rpgle
14c14
< // SOURCERER-FAIL declarations do not fit before source line 6: later statement numbers move
---
> // SOURCERER-FAIL declarations do not fit before source line 6: 4 lines missing
diff -r -x emit.ndjson -x *.receipt.json /Users/someara/data/sourcerer-loop/runs/emitbytes.zcb3m6/base-emit/242-P892E45BCS.rpgle /Users/someara/data/sourcerer-loop/runs/emitbytes.zcb3m6/head-emit/242-P892E45BCS.rpgle
13c13
< // SOURCERER-FAIL declarations do not fit before source line 6: later statement numbers move
---
> // SOURCERER-FAIL declarations do not fit before source line 6: 3 lines missing
forms projection differs:
33c33
< {"twin":"savf/SC-CONSTRUCT/TRPG3","object":"TRPG3","status":"done","statements":74,"emitted":60,"failures":15,"lines":148,"form_counts":{"compiler_policy_marks_v1":17,"context_character_literal_v1":17,"context_pointer_store_v1":17,"context_procedure_pointer_store_v1":17,"context_zero_fill_v1":17,"copied_character_argument_v1":1,"copied_packed_literal_argument_v1":1,"direct_branch_v1":7,"emit_assign_field_v1":10,"emit_call_program_v1":1,"emit_callp_v1":2,"emit_ctl_opt_v1":1,"emit_dcl_pi_v1":16,"emit_dcl_pr_v1":1,"emit_dcl_proc_v1":15,"emit_dcl_s_v1":8,"emit_end_pi_v1":16,"emit_end_pr_v1":1,"emit_end_proc_v1":17,"emit_endif_v1":1,"emit_free_v1":1,"emit_if_v1":1,"emit_pi_parameter_v1":18,"emit_pr_parameter_literal_v1":2,"emit_return_value_v1":13,"emit_summary_v1":2,"fail_procedure_boundary_v1":4,"fail_statement_v1":10,"fail_trailer_v1":1,"initialization_entry_v1":17,"initialization_resume_v1":17,"integer_store_v1":17,"layout_blank_v1":7,"local_pointer_store_v1":1,"null_pointer_literal_v1":1,"placeholder_return_value_v1":1,"procedure_character_literal_v1":1,"procedure_end_guard_v1":15,"procedure_exit_transfer_v1":18,"procedure_packed_literal_v1":1,"procedure_return_v1":17,"time_dtz_call_v1":1},"text_sha256":"2ce50ece5288de03fdd41468a5cc3bcd109e3016efc38c37a842a0b3d948a42d"}
---
== d. captures (capture-emit-diff)
l10-async-asyncage base=[584,309,278] head=[584,309,278] CHANGED fail-lines=278
l10-async-asyncdemo base=[621,333,291] head=[621,333,291] CHANGED fail-lines=291
l10-async-asyncbg base=[597,314,285] head=[597,314,285] CHANGED fail-lines=285
l10-async-asynccncl base=[608,324,287] head=[608,324,287] CHANGED fail-lines=287
l10-async-asyncprom base=[619,316,305] head=[619,316,305] CHANGED fail-lines=305
l10-async-asynctime base=[630,340,294] head=[630,340,294] CHANGED fail-lines=294
capture-emit-diff: 11 cases, 6 changed, 1 with no failure line in the head emit
== e. source agreement (agree)
suspect        base=78 head=78
conflict       base=0 head=0
params_wrong   base=15 head=15
decl_missing   base=81 head=81
decl_extra     base=25 head=25
type_unmarked  base=47 head=47
gate: PASS
## rpg_source_forms.zig, rpg_source_render_emit.zig: the trailer for declarations that do not fit says how many lines are missing The compiler numbers a statement by its source line, so a program whose declarations need more lines than the lines before its first statement shifts every statement after them, and it can never match. The emit already says so in a trailer. The trailer now also says how many lines the declarations lack: before: // SOURCERER-FAIL declarations do not fit before source line 7: later statement numbers move after: // SOURCERER-FAIL declarations do not fit before source line 7: 2 lines missing `Layout.missing` is the sum of the rises of the displacement of numbered lines (`Layout.push`): the lines by which text that has no number pushed a numbered line below its number, counted again only where the push grows; a numbered line that lands on its number ends the push. It is the shortfall under the rule the emitter applies now (the declarations of a scope go on the lines before the first statement of that scope). The text keeps the prefix `declarations do not fit before source line N` that `rt-stmt-diff.sh`, `agree.awk` and `emit-families.awk` read. The tail "later statement numbers move" is gone: with the count the line is 78 to 82 characters (the old one was 92 to 94), and `clip` cuts a trailer at 100. Both trailer sites (`render` and `renderColumns`) use one helper. Nothing else in any emit changes. No placement rule is shipped. No public compiled source puts a declaration after an executable statement, so the objects do not say whether the compiler accepts it or whether it changes the object (see "Why no placement rule yet"). ### Measure (2026-11-13, v0.1.513, every public emit with the trailer) Trailer counts before and after this change: Async 6, scout2 1, committed twins 28 (the same programs; the committed twin `ldsv-asyncprom` is the Async program `asyncprom`, so 34 distinct programs, 35 emits). Of the 19 scout2 captures one carries the trailer (barrettotte-vscode-ibmi-languages-1), not 7. The brief's 7 may be Async 6 plus this 1; that is a guess. Where the source put its declarations: in none of the 35 programs after an executable statement of the same scope. The fixed-form twins cannot (D before C). The 7 free-form captures: every local declaration directly after `end-pi`, every global before the first `dcl-proc`. A search for a `dcl-s`, `dcl-c`, `dcl-ds` or `dcl-pr` that follows an executable statement of its scope, or a global that follows a `dcl-proc` or a module-level statement (`/IF DEFINED` blocks evaluated, continuation lines skipped, `on-exit` counted as code) finds none in 753 committed free-form sources (the rpg-corpus files hold several programs each, so they are left out), in the 25 captures, and in the 8 free-form dev5 sources. No compiled object decides the question. The Async emits (the lines are source lines; `need` = declaration and interface lines of the emit, `lead` = the lines the current rule has (before the first statement of each scope), `free` = all free lines of the scopes, contiguous or not, so `need > free` proves that no placement fits): | emit | scopes | scopes over | lines missing | need | lead | free | |---|---|---|---|---|---|---| | l10-async-asyncage | 51 | 15 | 50 | 323 | 805 | 832 | | l10-async-asyncdemo | 52 | 15 | 50 | 332 | 828 | 864 | | l10-async-asyncbg | 52 | 15 | 50 | 326 | 861 | 891 | | l10-async-asynccncl | 53 | 15 | 50 | 333 | 834 | 866 | | l10-async-asyncprom | 51 | 16 | 56 | 337 | 837 | 874 | | l10-async-asynctime | 54 | 15 | 50 | 340 | 834 | 866 | In each program 15 scopes (asyncprom 16) are over, and none of them packs in order into the free runs of its procedure (a block of lines is one run). In 13 of them the whole procedure, blank lines after the first statement included, has fewer free lines than the emit has declaration lines: 44 lines short in all even if every free line were usable. Gaps cannot fix a program of this kind. The cause is the size of the declarations: asyncage has 38 local `dcl-ds ... likeds(task_t) based(p)` lines in the source, one each. The emit recovers 18 of them as full structures of 100 lines in all (18 `dcl-ds`, 35 filler lines `Gn char(k)`, 29 subfield lines, 18 `end-ds;`), where the source spends 18 lines. (`likeds` of the template and a `pos()` subfield in place of a filler would shorten them; neither is in this change, and `pos()` is not proved.) The scout2 emit: l10-barrettotte-vscode-ibmi-languages-1 is a different defect. The `on-exit` section is written as a procedure `_QRNI_ON_EXIT_MAIN` with `dcl-pi` / one failing parameter / `end-pi` (3 lines) where the source has the line `on-exit;` (line 49) and no interface, so `*inlr = *on;` (source line 50) lands on line 53. It misses 3 lines. Twins whose `on-exit` is recognized write `on-exit;` (e.g. P700F32C9S). The 28 committed twins (rows with `n/m` are programs whose statement numbers are not source lines because the compiler numbers the generated I/O lines, so `lead` and `free` are not computed): | twin (src/testdata/savf/) | first line moved | lines missing | need | lead | free | failure lines incl. the trailer | |---|---|---|---|---|---|---| | SC-ILE/EXPERIMENTS/l3b-ds-const | 10 | 1 | 10 | 9 | 9 | 1 | | SC-ILE/EXPERIMENTS/lv-pds-pi-ds | 12 | 1 | 12 | 11 | 11 | 1 | | SC-ILE/ACCESS | 18 | 1 | 17 | 16 | 16 | 7 | | SC-ILE/OPS/ws-fixed-stripped | 3 | 1 | n/m | n/m | n/m | 1 | | SC-ILE/EXPERIMENTS/r5x-cycle-print | 4 | 1 | 4 | 3 | 5 | 11 | | SC-ILE/OPS/fixed-exsr-stripped | 5 | 1 | n/m | n/m | n/m | 1 | | SC-ILE/EXPERIMENTS/lsel-for-arr-if-if | 43 | 2 | 33 | 49 | 49 | 14 | | SC-ILE/EXPERIMENTS/packed-add-held | 5 | 2 | 8 | 10 | 10 | 1 | | SC-ILE/EXPERIMENTS/packed-compose-held | 5 | 2 | 8 | 15 | 15 | 2 | | SC-ILE/EXPERIMENTS/lv-af-qual, -evalh, -evalr, -dech | 7 | 2 | 8 | 6 | 8 | 1 | | SC-ILE/EXPERIMENTS/lv-af-zadd-packed, -mult-zoned, -mult-f1, -mult-f2, -add-zoned | 7 | 2 | 8 | 6 | 6 | 1 | | SC-ILE/OPS/subst-stripped | 7 | 2 | 8 | 6 | 6 | 2 | | SC-ILE/FLOW/fx-held-stripped | 1 | 3 | 3 | 0 | 0 | 11 | | SC-ILE/FLOW/fx-held2-stripped | 1 | 3 | 3 | 0 | 0 | 12 | | SC-ILE/EXPERIMENTS/lr1-ec-loop-next | 10 | 3 | 12 | 9 | 9 | 1 | | SC-CONSTRUCT/TRPG3 | 4 | 3 | 64 | 71 | 71 | 15 | | SC-ILE/EXPERIMENTS/l3b-subst-const | 6 | 3 | 8 | 5 | 5 | 2 | | SC-ILE/CALLS/pc-call-stripped | 4 | 4 | 7 | 3 | 7 | 2 | | SC-ILE/EXPERIMENTS/l3b-elem-const | 6 | 4 | 9 | 5 | 5 | 1 | | SC-ILE/EXPERIMENTS/init-auto-char-heldout | 11 | 5 | 7 | 6 | 6 | 3 | | SC-ILE/EXPERIMENTS/ldsv-asyncprom | 523 | 56 | 337 | 837 | 874 | 305 | (`need` counts the `**FREE` line, `ctl-opt`, file declarations and the interface; the statement numbers of the two programs marked `n/m` (`ws-fixed`, `fixed-exsr`) are not lines: the first calculation of `fixed-exsr` is statement 9 on source line 5, because the compiler numbers the lines it generates for the file. `fx-held` and `fx-held2` have a calculation on line 1, so no line is free before it.) 16 of the 28 have no failure line except the trailer: l3b-ds-const, lv-pds-pi-ds, packed-add-held, the nine `lv-af-*`, lr1-ec-loop-next, l3b-elem-const, ws-fixed and fixed-exsr; so these 16 are the programs that a fit would turn into candidates for a host round trip. None of the 28 is `match` in the newest matrix snapshot (`base-v0.1.513.ndjson`: 25 `different`, 3 `failed`). What the 16 need: a fixed-form source spends one line on `H`, each `F`, each `D` and the subfields of a structure; the free-form emit spends the same lines plus `**FREE` and an `end-ds;` for each structure, and has no free line in the source to take them (`lv-af-evalh`: six source lines before the first statement, eight emitted; the two free lines at 8 and 10 are `/FREE` and `/END-FREE`, one line each, and the four-line `dcl-ds` is one block). No fit is possible by placement. ### Why no placement rule yet Placing a declaration after an executable statement is accepted or refused by the compiler, and the objects do not say which: no public compiled program does it (search above), so a rule would be a guess. Wrong text without a failure line is worse than a refusal, and a refused compile turns a program with a trailer into one that fails to build. The measure above shows how little the rule could win: even if the compiler accepted every placement, 32 of the 35 emits have a scope whose declaration blocks do not pack in order into its free runs (a block is one run), so no placement fits them. The other three are `r5x-cycle-print` (11 failure lines) and `fixed-exsr` and `ws-fixed`, whose statement numbers are not lines (not computed) and whose sources have no blank or comment line, so there is no free line to place anything on. The four `lv-af-*` twins with `free` = `need` show the limit: the free runs are lines 1 to 6, 8 and 10, and the structure is one block of 4 lines. Packing two statements on one line is closed too until it is measured: `docs/DUMP.md` records RNF5508 for two statements on a line, and the matrix has the three twins whose emit has `chain ...; *in90 = ...` on one line (`fk-fixed`, `fk-fixed2`, `fk-multifix`) as `failed`. `~/data/sourcerer-loop/requests/ldfit/place/` (manifest, 24 cases, README) is the battery: every variant is the base of its family with one declaration moved to a line that the base keeps blank, so every statement stays on its line. Cycle program (M, 8 cases): `dcl-s`, `dcl-c`, a four-line `dcl-ds` and a four-line `dcl-pr` between two calculations, `dcl-s` after the first use (refusal expected), `dcl-s` after the last calculation, two declarations swapped. Procedure (P, 7 cases): the same kinds local, a local `static`. Global between two procedures, before and after the using one (G, 4 cases). The same procedure cases with `option(*srcstmt)` (S, 2 cases). Statements on one line (L, 3 cases: two `dcl-s`, `ctl-opt` and `dcl-s`, a whole `dcl-ds`). The README says how to read each answer: the compile result, the operations and statement numbers against the base, the symbol list, the static initialization order. The manifest lists the cases that must compile first (the four bases and the swap), then the unknowns, then the three `l-*` cases (refusal expected, RNF5508), then the three that name a field before its declaration (refusal certain). The batch runner stops at the first refused compile, so the README says how to rerun the rest into a fresh destination. ### Who reads the trailer `rt-stmt-diff.sh` (pairs by order when the emit holds `declarations do not fit before source line`), `agree.awk` (`declarations do not fit`) and `emit-families.awk` (`do not fit before`) match a prefix that the new text keeps. `reason-audit.sh` takes the first failure line that names `statement N`: the old trailer ended `statement numbers move` (no digits) and the new one has no `statement`, so for the 16 twins whose only failure is the trailer it finds no failure line either way. The fixture of `tests/rt-stmt-diff.sh` has its own text. The header comments of `rt-stmt-diff.sh` and `agree-twins.sh` still quote the old tail; they are in `sean/sourcerer-loop`, not here. ### Proof - `src/rpg_decl_fit_test.zig` (registered in `src/root.zig`): `lv-af-evalh` reads `7: 2 lines missing` (red before: `Layout` had no count), `fk-subp` has no trailer and its statements stay on their lines, and `Layout` counts the rises of the displacement and not the lines of the displacement itself (5 declaration lines before line 4: 3 missing; the next statement stays 3 below its line: still 3; a line on its number ends it; a second scope short by 2: 5). - `emit-all.sh` with the base binary (v0.1.513) and with this branch, on the 826 emitted twins: a `cmp` of every file finds 28 changed (the 28 above), and `diff` of each shows only the lines with `declarations do not fit`. The summary line is equal (`failures` 928, `emitted` 8422, `clean` 593). The 854 receipts are equal at `statements`, `emitted`, `failures`, `placeholders`, `form_counts`, the number of lines and the form of each line, so no form moves. `capture-emit-diff.sh` over the 25 public captures with the branch binary of this ship: 25 cases, 7 changed (6 Async, barrettotte), each by its trailer line only, statements, emitted and failures equal in all 25, and no head emit without a failure line. `emit-bytes-diff.sh` exits 1 by design and prints the first 20 lines of each diff: the trailer line of `P92F0A341S`, `PABC59092S`, `PD55A2B53S` and `P892E45BCS`, and rows of the forms projection that differ in `text_sha256` only (`form_counts`, `lines`, `statements`, `emitted` and `failures` are equal in every row it printed). None of the 28 is `match` in the matrix. - The count matches the shortfall computed outside the emitter (statement positions of the old emit): asyncage 50, asyncprom 56, barrettotte 3, and 26 of the 28 twins agree to the line. The two that differ, `fixed-exsr` and `ws-fixed` (the script says 0, the emitter 1), have statement numbers that are not lines. - `ship.sh`: census 645 / 0 regressions, golden, legend current, emit `worse` empty, twins and allgroups regressions empty, unit, full check. ## Gate ``` diff -r -x emit.ndjson -x *.receipt.json /Users/someara/data/sourcerer-loop/runs/emitbytes.zcb3m6/base-emit/240-PD55A2B53S.rpgle /Users/someara/data/sourcerer-loop/runs/emitbytes.zcb3m6/head-emit/240-PD55A2B53S.rpgle 14c14 < // SOURCERER-FAIL declarations do not fit before source line 6: later statement numbers move --- > // SOURCERER-FAIL declarations do not fit before source line 6: 4 lines missing diff -r -x emit.ndjson -x *.receipt.json /Users/someara/data/sourcerer-loop/runs/emitbytes.zcb3m6/base-emit/242-P892E45BCS.rpgle /Users/someara/data/sourcerer-loop/runs/emitbytes.zcb3m6/head-emit/242-P892E45BCS.rpgle 13c13 < // SOURCERER-FAIL declarations do not fit before source line 6: later statement numbers move --- > // SOURCERER-FAIL declarations do not fit before source line 6: 3 lines missing forms projection differs: 33c33 < {"twin":"savf/SC-CONSTRUCT/TRPG3","object":"TRPG3","status":"done","statements":74,"emitted":60,"failures":15,"lines":148,"form_counts":{"compiler_policy_marks_v1":17,"context_character_literal_v1":17,"context_pointer_store_v1":17,"context_procedure_pointer_store_v1":17,"context_zero_fill_v1":17,"copied_character_argument_v1":1,"copied_packed_literal_argument_v1":1,"direct_branch_v1":7,"emit_assign_field_v1":10,"emit_call_program_v1":1,"emit_callp_v1":2,"emit_ctl_opt_v1":1,"emit_dcl_pi_v1":16,"emit_dcl_pr_v1":1,"emit_dcl_proc_v1":15,"emit_dcl_s_v1":8,"emit_end_pi_v1":16,"emit_end_pr_v1":1,"emit_end_proc_v1":17,"emit_endif_v1":1,"emit_free_v1":1,"emit_if_v1":1,"emit_pi_parameter_v1":18,"emit_pr_parameter_literal_v1":2,"emit_return_value_v1":13,"emit_summary_v1":2,"fail_procedure_boundary_v1":4,"fail_statement_v1":10,"fail_trailer_v1":1,"initialization_entry_v1":17,"initialization_resume_v1":17,"integer_store_v1":17,"layout_blank_v1":7,"local_pointer_store_v1":1,"null_pointer_literal_v1":1,"placeholder_return_value_v1":1,"procedure_character_literal_v1":1,"procedure_end_guard_v1":15,"procedure_exit_transfer_v1":18,"procedure_packed_literal_v1":1,"procedure_return_v1":17,"time_dtz_call_v1":1},"text_sha256":"2ce50ece5288de03fdd41468a5cc3bcd109e3016efc38c37a842a0b3d948a42d"} --- == d. captures (capture-emit-diff) l10-async-asyncage base=[584,309,278] head=[584,309,278] CHANGED fail-lines=278 l10-async-asyncdemo base=[621,333,291] head=[621,333,291] CHANGED fail-lines=291 l10-async-asyncbg base=[597,314,285] head=[597,314,285] CHANGED fail-lines=285 l10-async-asynccncl base=[608,324,287] head=[608,324,287] CHANGED fail-lines=287 l10-async-asyncprom base=[619,316,305] head=[619,316,305] CHANGED fail-lines=305 l10-async-asynctime base=[630,340,294] head=[630,340,294] CHANGED fail-lines=294 capture-emit-diff: 11 cases, 6 changed, 1 with no failure line in the head emit == e. source agreement (agree) suspect base=78 head=78 conflict base=0 head=0 params_wrong base=15 head=15 decl_missing base=81 head=81 decl_extra base=25 head=25 type_unmarked base=47 head=47 gate: PASS ```
Say how many lines the declarations lack when they do not fit before the first statement
Some checks reported errors
binjovi/ci A newer source or plan superseded this Build
7629943888
The trailer "declarations do not fit before source line N" now ends with
"M lines missing": the sum of the rises of the displacement of numbered lines
(Layout.missing). No placement rule: the objects do not say whether a
declaration may follow an executable statement, so the battery
requests/ldfit/place asks, and the fragment holds the measure of the 35
emits that carry the trailer.
sean force-pushed ldfit from 7629943888
Some checks reported errors
binjovi/ci A newer source or plan superseded this Build
to 83a64769f8
All checks were successful
binjovi/ci Binjovi completed the frozen plan
2026-11-13 23:00:06 +00:00
Compare
binjovi-bot manually merged commit 83a64769f8 into trunk 2026-11-13 23:13:01 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sean/sourcerer!798
No description provided.