rpg_source_stmt.zig, rpg_source.zig, rpg_source_decl_emit.zig: a conversion as a procedure argument, and refusal trace sites in the emitter #771

Manually merged
binjovi-bot merged 6 commits from lgd into trunk 2026-11-09 02:20:38 +00:00
Owner

rpg_source_stmt.zig: the held-out _QRNX_GET_DECIMAL_NUM family is a runtimeSummary refusal, not a declaration refusal (lane Lgd)

What the two labels prove (code reading, trunk 5be4b586)

  • A statement that names a symbol whose declaration failed is re-marked after it was
    translated: rpg_source_decl_emit.zig (the loop after charNow, and failUndeclared)
    turns a .code entry into (no declaration of symbol N: <why>). Both loops skip an
    entry that is already .fail.
  • emit-families.awk tests /no declaration of symbol/ before the runtime rule and
    unconditionally, and withReason cuts the statement text so that the reason stays. A
    %DEC statement blocked by its declaration is therefore classed "statement names a field
    without a declaration / line longer than 100 bytes" (the public battery lr1-long-decl
    shows it: statement 13: S... (no declaration of symbol 253: a line is longer than 100 bytes)).
  • The label "runtime or packed template statement / _QRNX_GET_DECIMAL_NUM" needs a fail line
    that starts with the raw CALL _QRNX_GET_DECIMAL_NUM( segment, has no partial: and no
    reason. The only producer is rpg_source.zig statement: stmt.hasSegments(text) and
    stmt.runtimeSummary returned null, then .fail = text. The fail line is clipped at 100
    bytes, so only the first segment (the call) is visible; whatever made the summary refuse is
    after it.

So the two statements fail inside runtimeSummary, before the declaration is looked at. The
long declaration of their source is a second, independent refusal of the same symbol. The three
earlier attempts (Lr1 subfield conversions, the twelve-line INZ, *allx image fields,
*HIVAL/*LOVAL, Lo15 %DEC(%CHAR(I))) changed the declaration side or the proof side only;
none of them can move a statement that runtimeSummary refuses, which is why the family stayed
unchanged. Both gates must open for the statements to emit.

The gates of runtimeSummary for a recovered decimal statement, ranked

The proof text of a recovered _QRNX_GET_DECIMAL_NUM statement is
CALL _QRNX_GET_DECIMAL_NUM(...); IF RETURN <> 0: ...; Lnn AT I..I..; <other lines>; <final>,
the lines of rpg_eval joined by ; (rpg_statements.zig). Conditions (IF, DOW, WHEN)
drop the call lines (rpg_eval keeps decimal_lines out of a condition), so a condition is no
candidate: h-numtrim statement 13 if %int(%trim(parm)) > 3 emits.

  1. The final is no assignment and no RETURN (indexOf(final, " = ") == null). A procedure
    called as a statement with the conversion as an argument: rpg_eval.call appends
    CALLP name(args) to the lines when the result is dropped, so the final is
    CALLP SHOWI(%INT(...)). No public twin has callp p(%dec(char)) or p(%int(char))
    (the public invoke(%dec(i10: 9: 2): text) is a numeric %DEC, no call). Ranked first:
    it is a certain refusal in the code and a common form (a long input buffer whose fields
    are passed to subprocedures).
  2. A segment without a rule after the call (the else of the segment loop). A CONST
    packed or zoned parameter takes the conversion through a checked copy
    (programs.op_checked_copy: a COPY_REF... line); a character target takes
    %CHAR(%DEC(...)) through copy lines (%SUBST(T: 1: n) = ...); an element target can
    write %SUBST(elem: ...). Each is after the call, so the label stays GET_DECIMAL_NUM.
  3. The final names neither %DEC( nor %INT( (line 240). %UNS, %UNSH, %INTH (and
    %DECH on trunk, which lr1g extended) fail this test if the proof recovers them; on trunk
    recoverFrom requires the half-adjust constant 0 (s12), so %INTH/%DECH are partial,
    not recovered, and rank below; %UNS keeps the call shape and may be recovered.
  4. A FOR limit or a DSPLY operand whose evaluation is written as lines (unmeasured).
  5. Quote imbalance in the text (quoted at the end): an apostrophe in a source literal; low.

The declaration side, ranked (the second gate, same symbol)

declLine (scalar) and structureLines (data structure) refuse "longer than 100 bytes" when
a line still passes 100 bytes after wrapLong, which allows at most two INZ continuation lines
(about 176 characters of text, 88 bytes as hexadecimal). The name and the type are short, so
the length is the INZ:

  1. A character field or subfield with a long text start value (more than about 176
    characters): a record or message buffer whose numeric fields the program converts. Lr1g's
    twelve-line rule would open it, but only together with a statement-side rule.
  2. Any start value with one byte that is not invariant (characterLiteral writes the whole
    value as hexadecimal, twice its length): more than 88 bytes.
  3. A filler of a structure with a mixed image (packed, binary and text bytes, no period of 8
    bytes or less), more than 88 bytes.
  4. A dim + ctdata (or perrcd) table: the whole image of an array is refused.
  5. Unmeasured: a PSDS subfield source, a static varchar with a long start value.

Battery lgd/decnum (requests/lgd/decnum)

Consumers × long declarations, each case one conversion statement of the long-declared symbol;
two plain-field controls separate the statement gate from the declaration gate.

case declaration statement tests
lgd-a-assign char(200) text p = %dec(%subst(line: 4: 5): 7: 0) control, decl gate 1
lgd-a-callp-int, -call-int char(200) text callp showi(%int(%subst(...))), showi(...) stmt gate 1
lgd-a-callp-pk char(200) text callp showp(%dec(...: 7: 0)) (CONST packed) stmt gate 2 (checked copy)
lgd-a-char-tgt, -editc char(200) text c = %char(%dec(...)), c = %editc(%dec(...): 'Z') stmt gate 2 (copy lines)
lgd-a-elem-tgt char(200) text arr(2) = %dec(...) stmt gate 2 (element store)
lgd-a-uns, -inth char(200) text u = %uns(...), n = %inth(...) stmt gate 3
lgd-a-for, -dsply char(200) text FOR limit, dsply %char(%int(...)) stmt gate 4
lgd-a-whole char(200) text n = %int(line) (all 200 bytes) the length of the source
lgd-d-* (6) structure with a char(200) text subfield assign, callp int, callp packed, char target, %uns, store into the same structure decl gate 1 (structure path) × stmt gates
lgd-t-* (4) char(5) dim(40) ctdata (200-byte image) constant index, variable index, callp, char target decl gate 4
lgd-x-* (2) none callp showi(%int(s10)), u = %uns(s10) stmt gate alone

A case reproduces the held-out pair when its emit has both a fail line that starts with
CALL _QRNX_GET_DECIMAL_NUM( (no partial:) and declaration of symbol N: ... longer than 100 bytes for the symbol the call reads.

Trace sites in runtimeSummary (instrumentation, no behaviour change)

rpg_source_stmt.runtimeSummary returned null silently, so the refusal tracer could not
name the gate. Each null return is now rpg_trace.ret(null, "rpg_source_stmt", "runtimeSummary", "sNN"), s01 to s22 in the order of the returns (s03: the final is no
assignment and no RETURN; s13: a segment without a rule; s15: no %DEC(/%INT( in the
final; s14, s18, s20: the edit, date and conversion mismatches; s22: a padded store with no
call that plainStore refuses). The file is in the site list of rpg_trace_test.zig. The
tokens fire under savf rpgle (the emitter), not under dump. On the committed twins
(Debug build, every stripped save of src/testdata) only s10 (h-now2), s13 (dict-calls3,
h-blk1, h-subfill, r5x-cycle-print), s20 (h-now1) and s22 (lc2-concat-arr, lc2-concat-ds)
fire; s03 and s15 fire on none. The emitted source of every twin is byte-identical to the
trunk Debug build. Tests: src/rpg_lgd_test.zig (s03 for a CALLP final, s15 for %UNS,
no token for the assignment).

Oracle round 1 and the second set of trace sites

The coordinator's oracle on the first build: no runtimeSummary site fires on the two programs
with the family, and the declaration line did not move under any lr1g build. So the fail text
that carries CALL _QRNX_GET_DECIMAL_NUM comes from another branch that keeps the proof text.
Candidates: a fail that withReason writes as the proof text plus a short reason that
emit-families.awk has no rule for. The awk classes it by : CALL _QRNX before its later rules,
and a reason of about 35 bytes or fewer leaves CALL _QRNX_GET_DECIMAL_NUM( visible. The first
candidate is checkNames "the name X is not declared" (or "names no symbol"). The emitted text
names a field whose declaration lines declare no name, because the declaration failed, through a
piece that the .symbol/.part loop of declare does not see.

New sites (output unchanged; every twin's emit is byte-identical to trunk):

  • rpg_source.statement s01 checkedCall, s02 decimalCall, s03 packedFact, s04 fileStatement:
    each returned a fail; s05: runtimeSummary succeeded and the statement of the final failed.
  • rpg_source.translate s01 status (partial/unresolved), s02 field at byte 0 narrower, s03
    part_why, s04 pointer reason, s05 token reason, s06 any fail at the end.
  • rpg_source_decl_emit.declare s01 date start value, s02 byte of a non-structure, s03 no
    declaration, s04 file field, s05 temporal subfield, s06 interface not emitted;
    balance s01 block not whole; failUndeclared s01; checkNames s01 without DIM, s02 element
    outside the dimension, s03 names no symbol, s04 is not declared.

On the committed twins, these never fire: rpg_source.statement s01, rpg_source.translate s02,
declare s01, declare s05, checkNames s02, checkNames s03. checkNames s04 fires only on
lr1-af-z50-200-blank.

Oracle round 2: checkNames s04, and why lr1g did not move it

The coordinator's oracle on lgd-debug2: on the two programs only checkNames s04 ("the name X is
not declared") fires. The mechanism: a declaration refused by declLine (the scalar path, which
includes an array, isStructure is false for e.arrays) as "longer than 100 bytes" is a fail
line written while the lines are written. d.failure is never set, so neither declare nor
failUndeclared (structures only) marks the statements. checkNames then finds the generated
name in the emitted text with no declaring line and writes the proof text, which starts with
CALL _QRNX_GET_DECIMAL_NUM(, plus a reason of about 31 bytes. The awk has no rule for the reason,
so the label is the runtime family.

The one public twin with checkNames s04, lr1-af-z50-200-blank (a structure of zoned(5:0) dim(200) inz(1) and char(10), declared on trunk as a whole-symbol array), already emits clean on
lr1g (origin/lr1g 0daba11a, Debug build: dcl-ds A_00253; A_00253_F0 zoned(5:0) dim(200) inz(1); A_00253_G1000 char(10); end-ds;, statements 5, emitted 5, failures 0). lr1g did not move the
held-out declaration, so the held-out symbol is a scalar-path declaration that lr1g still
refuses. Candidates ranked:

  1. A standalone array whose image is no single element value (ctdata, or elements that differ):
    lr1g keeps "the image of a whole array" refused. Battery cases lgd-t-*.
  2. A character field whose start value is longer than the twelve lines of lr1g, or one that has a
    byte that is not invariant (hexadecimal at twice its length). Battery cases lgd-a-* cover
    the trunk limit only.
  3. A structure that the emitter declares whole as an array or a character field (no part
    proved at a byte other than 0) and that lr1g's array subfield rule does not reach.

Loop-side note (not in this PR)

emit-families.awk has no rule for the checkNames reasons "the name X is not declared" and
"the name X names no symbol". A statement that checkNames fails keeps its proof text, so a
runtime-call statement is classed "runtime or packed template statement / " and hides
that its cause is a declaration. The coordinator gives these reasons their own label in the loop.

lgd is rebased onto trunk 0daba11a (v0.1.487, lr1g merged); the %DECH( test of lr1g in
runtimeSummary keeps its site s15.

Battery lgd/decnum on v0.1.487: negative for the held-out pair

The 24 captures (captures/lgd-decnum, the t-* table renamed codes: a name that starts with TAB
is a table, RNF0752) emitted with a v0.1.487 Debug build. No case fires checkNames s04, and no
declaration is refused:

cases result tokens
a-assign, a-char-tgt, a-editc, a-inth, a-whole clean none
a-callp-int, a-call-int, a-callp-pk, t-callp, x-callp-plain raw CALL _QRNX_GET_DECIMAL_NUM( runtimeSummary s03
t-elem, t-char "the name A_00256 is declared without DIM and takes no index" checkNames s01
a-elem-tgt S254.4 = ... (S254.4: no type): the target arr(2) statement s05
a-uns, a-dsply, x-uns-plain, d-* (6), t-assign partial (the proof): %UNS is written %DEC(F); %DEC of a char subfield at byte 0 of a structure with more subfields none
a-for unresolved none

Ruled out as the held-out declaration (each emits its declaration on v0.1.487):

  • a text start value of 193 characters, standalone or as a structure subfield (lr1g's lines);
  • the whole image of a ctdata array: declared char(200) with the image, not refused (it fails
    the statements with checkNames s01, another reason).

What the oracle still requires: the symbol is refused by declLine or structureLines as longer
than 100 bytes on v0.1.487, it is not a structure that failUndeclared reaches, and a statement
names it in its emitted text.

Second battery (proposal, not written)

At most 12 cases, each one %DEC/%INT read of the symbol in an assignment (the form that emits
clean above):

  1. A start value with a byte that is not invariant (characterLiteral writes all of it in
    hexadecimal), 50, 90 and 150 bytes: char(N) inz('... $ ...') or inz(x'..25..').
  2. A text start value over twelve lines (more than about 1000 characters): char(1200) inz(...).
  3. A structure declared whole (no part at a byte other than 0): %DEC of the whole structure
    ds (dcl-ds ds; a char(5) inz('00012'); b packed(9:2) inz(1); ...), with a mixed image over
    88 bytes, the %dec(ds: 15: 0) form.
  4. A standalone array of distinct start values not from ctdata (dim(40) with a pos overlay
    start value, or inz per element through a structure dim).
  5. A varchar with a long start value read by %INT, and a based field.

Rule in this PR: a conversion as the argument of a procedure called as a statement

rpg_source_stmt.runtimeSummary took an assignment or a RETURN as the final effect only. A
procedure called as a statement (callp showi(%int(...)), showi(...), callp showp(%dec(...: 7: 0)) with a CONST packed parameter) ends in CALLP P(...), and the summary refused it (s03). It
now takes CALLP too; the other gates are unchanged. The five public captures (lgd-a-callp-int,
-call-int, -callp-pk, lgd-t-callp, lgd-x-callp-plain) then emit, for example,
SHOWP(%DEC(%SUBST(A_00258: 4: 5): 7: 0)); (lgd-t-callp still fails checkNames s01 on its
table). Test: src/rpg_lgd_test.zig (the CALLP summary, and s03 still for a DSPLY final). The
round trip of these captures is the coordinator's.

Gates (Debug, base trunk 0daba11a, new lgd): twins-diff 811 groups, 789 recovered, no
regression, none newly recovered (an emitter-only change); emit-diff no worse, no better, 571
clean of 773 on both (no committed twin has the form; the gain is on the lgd-decnum captures).

# rpg_source_stmt.zig: the held-out _QRNX_GET_DECIMAL_NUM family is a runtimeSummary refusal, not a declaration refusal (lane Lgd) ## What the two labels prove (code reading, trunk 5be4b586) - A statement that names a symbol whose declaration failed is re-marked after it was translated: `rpg_source_decl_emit.zig` (the loop after `charNow`, and `failUndeclared`) turns a `.code` entry into `(no declaration of symbol N: <why>)`. Both loops skip an entry that is already `.fail`. - `emit-families.awk` tests `/no declaration of symbol/` before the runtime rule and unconditionally, and `withReason` cuts the statement text so that the reason stays. A `%DEC` statement blocked by its declaration is therefore classed "statement names a field without a declaration / line longer than 100 bytes" (the public battery `lr1-long-decl` shows it: `statement 13: S... (no declaration of symbol 253: a line is longer than 100 bytes)`). - The label "runtime or packed template statement / _QRNX_GET_DECIMAL_NUM" needs a fail line that starts with the raw `CALL _QRNX_GET_DECIMAL_NUM(` segment, has no `partial:` and no reason. The only producer is `rpg_source.zig statement`: `stmt.hasSegments(text)` and `stmt.runtimeSummary` returned null, then `.fail = text`. The fail line is clipped at 100 bytes, so only the first segment (the call) is visible; whatever made the summary refuse is after it. So the two statements fail inside `runtimeSummary`, before the declaration is looked at. The long declaration of their source is a second, independent refusal of the same symbol. The three earlier attempts (Lr1 subfield conversions, the twelve-line INZ, `*allx` image fields, `*HIVAL`/`*LOVAL`, Lo15 `%DEC(%CHAR(I))`) changed the declaration side or the proof side only; none of them can move a statement that `runtimeSummary` refuses, which is why the family stayed unchanged. Both gates must open for the statements to emit. ## The gates of runtimeSummary for a recovered decimal statement, ranked The proof text of a recovered `_QRNX_GET_DECIMAL_NUM` statement is `CALL _QRNX_GET_DECIMAL_NUM(...); IF RETURN <> 0: ...; Lnn AT I..I..; <other lines>; <final>`, the lines of `rpg_eval` joined by `; ` (`rpg_statements.zig`). Conditions (`IF`, `DOW`, `WHEN`) drop the call lines (`rpg_eval` keeps `decimal_lines` out of a condition), so a condition is no candidate: h-numtrim statement 13 `if %int(%trim(parm)) > 3` emits. 1. **The final is no assignment and no RETURN** (`indexOf(final, " = ") == null`). A procedure called as a statement with the conversion as an argument: `rpg_eval.call` appends `CALLP name(args)` to the lines when the result is dropped, so the final is `CALLP SHOWI(%INT(...))`. No public twin has `callp p(%dec(char))` or `p(%int(char))` (the public `invoke(%dec(i10: 9: 2): text)` is a numeric `%DEC`, no call). Ranked first: it is a certain refusal in the code and a common form (a long input buffer whose fields are passed to subprocedures). 2. **A segment without a rule after the call** (the `else` of the segment loop). A CONST packed or zoned parameter takes the conversion through a checked copy (`programs.op_checked_copy`: a `COPY_REF...` line); a character target takes `%CHAR(%DEC(...))` through copy lines (`%SUBST(T: 1: n) = ...`); an element target can write `%SUBST(elem: ...)`. Each is after the call, so the label stays GET_DECIMAL_NUM. 3. **The final names neither `%DEC(` nor `%INT(`** (line 240). `%UNS`, `%UNSH`, `%INTH` (and `%DECH` on trunk, which lr1g extended) fail this test if the proof recovers them; on trunk `recoverFrom` requires the half-adjust constant 0 (`s12`), so `%INTH`/`%DECH` are partial, not recovered, and rank below; `%UNS` keeps the call shape and may be recovered. 4. **A FOR limit or a DSPLY operand** whose evaluation is written as lines (unmeasured). 5. Quote imbalance in the text (`quoted` at the end): an apostrophe in a source literal; low. ## The declaration side, ranked (the second gate, same symbol) `declLine` (scalar) and `structureLines` (data structure) refuse "longer than 100 bytes" when a line still passes 100 bytes after `wrapLong`, which allows at most two INZ continuation lines (about 176 characters of text, 88 bytes as hexadecimal). The name and the type are short, so the length is the INZ: 1. A character field or subfield with a long text start value (more than about 176 characters): a record or message buffer whose numeric fields the program converts. Lr1g's twelve-line rule would open it, but only together with a statement-side rule. 2. Any start value with one byte that is not invariant (`characterLiteral` writes the whole value as hexadecimal, twice its length): more than 88 bytes. 3. A filler of a structure with a mixed image (packed, binary and text bytes, no period of 8 bytes or less), more than 88 bytes. 4. A `dim` + `ctdata` (or `perrcd`) table: the whole image of an array is refused. 5. Unmeasured: a PSDS subfield source, a static `varchar` with a long start value. ## Battery lgd/decnum (requests/lgd/decnum) Consumers × long declarations, each case one conversion statement of the long-declared symbol; two plain-field controls separate the statement gate from the declaration gate. | case | declaration | statement | tests | |---|---|---|---| | lgd-a-assign | char(200) text | `p = %dec(%subst(line: 4: 5): 7: 0)` | control, decl gate 1 | | lgd-a-callp-int, -call-int | char(200) text | `callp showi(%int(%subst(...)))`, `showi(...)` | stmt gate 1 | | lgd-a-callp-pk | char(200) text | `callp showp(%dec(...: 7: 0))` (CONST packed) | stmt gate 2 (checked copy) | | lgd-a-char-tgt, -editc | char(200) text | `c = %char(%dec(...))`, `c = %editc(%dec(...): 'Z')` | stmt gate 2 (copy lines) | | lgd-a-elem-tgt | char(200) text | `arr(2) = %dec(...)` | stmt gate 2 (element store) | | lgd-a-uns, -inth | char(200) text | `u = %uns(...)`, `n = %inth(...)` | stmt gate 3 | | lgd-a-for, -dsply | char(200) text | FOR limit, `dsply %char(%int(...))` | stmt gate 4 | | lgd-a-whole | char(200) text | `n = %int(line)` (all 200 bytes) | the length of the source | | lgd-d-* (6) | structure with a char(200) text subfield | assign, callp int, callp packed, char target, %uns, store into the same structure | decl gate 1 (structure path) × stmt gates | | lgd-t-* (4) | `char(5) dim(40) ctdata` (200-byte image) | constant index, variable index, callp, char target | decl gate 4 | | lgd-x-* (2) | none | `callp showi(%int(s10))`, `u = %uns(s10)` | stmt gate alone | A case reproduces the held-out pair when its emit has both a fail line that starts with `CALL _QRNX_GET_DECIMAL_NUM(` (no `partial:`) and `declaration of symbol N: ... longer than 100 bytes` for the symbol the call reads. ## Trace sites in runtimeSummary (instrumentation, no behaviour change) `rpg_source_stmt.runtimeSummary` returned null silently, so the refusal tracer could not name the gate. Each null return is now `rpg_trace.ret(null, "rpg_source_stmt", "runtimeSummary", "sNN")`, s01 to s22 in the order of the returns (s03: the final is no assignment and no RETURN; s13: a segment without a rule; s15: no `%DEC(`/`%INT(` in the final; s14, s18, s20: the edit, date and conversion mismatches; s22: a padded store with no call that `plainStore` refuses). The file is in the site list of `rpg_trace_test.zig`. The tokens fire under `savf rpgle` (the emitter), not under `dump`. On the committed twins (Debug build, every stripped save of `src/testdata`) only s10 (h-now2), s13 (dict-calls3, h-blk1, h-subfill, r5x-cycle-print), s20 (h-now1) and s22 (lc2-concat-arr, lc2-concat-ds) fire; s03 and s15 fire on none. The emitted source of every twin is byte-identical to the trunk Debug build. Tests: `src/rpg_lgd_test.zig` (s03 for a `CALLP` final, s15 for `%UNS`, no token for the assignment). ## Oracle round 1 and the second set of trace sites The coordinator's oracle on the first build: no `runtimeSummary` site fires on the two programs with the family, and the declaration line did not move under any lr1g build. So the fail text that carries `CALL _QRNX_GET_DECIMAL_NUM` comes from another branch that keeps the proof text. Candidates: a fail that `withReason` writes as the proof text plus a short reason that `emit-families.awk` has no rule for. The awk classes it by `: CALL _QRNX` before its later rules, and a reason of about 35 bytes or fewer leaves `CALL _QRNX_GET_DECIMAL_NUM(` visible. The first candidate is `checkNames` "the name X is not declared" (or "names no symbol"). The emitted text names a field whose declaration lines declare no name, because the declaration failed, through a piece that the `.symbol`/`.part` loop of `declare` does not see. New sites (output unchanged; every twin's emit is byte-identical to trunk): - `rpg_source.statement` s01 checkedCall, s02 decimalCall, s03 packedFact, s04 fileStatement: each returned a fail; s05: `runtimeSummary` succeeded and the statement of the final failed. - `rpg_source.translate` s01 status (partial/unresolved), s02 field at byte 0 narrower, s03 `part_why`, s04 pointer reason, s05 token reason, s06 any fail at the end. - `rpg_source_decl_emit.declare` s01 date start value, s02 byte of a non-structure, s03 no declaration, s04 file field, s05 temporal subfield, s06 interface not emitted; `balance` s01 block not whole; `failUndeclared` s01; `checkNames` s01 without DIM, s02 element outside the dimension, s03 names no symbol, s04 is not declared. On the committed twins, these never fire: `rpg_source.statement s01`, `rpg_source.translate s02`, `declare s01`, `declare s05`, `checkNames s02`, `checkNames s03`. `checkNames s04` fires only on lr1-af-z50-200-blank. ## Oracle round 2: checkNames s04, and why lr1g did not move it The coordinator's oracle on lgd-debug2: on the two programs only `checkNames s04` ("the name X is not declared") fires. The mechanism: a declaration refused by `declLine` (the scalar path, which includes an array, `isStructure` is false for `e.arrays`) as "longer than 100 bytes" is a fail line written while the lines are written. `d.failure` is never set, so neither `declare` nor `failUndeclared` (structures only) marks the statements. `checkNames` then finds the generated name in the emitted text with no declaring line and writes the proof text, which starts with `CALL _QRNX_GET_DECIMAL_NUM(`, plus a reason of about 31 bytes. The awk has no rule for the reason, so the label is the runtime family. The one public twin with `checkNames s04`, lr1-af-z50-200-blank (a structure of `zoned(5:0) dim(200) inz(1)` and `char(10)`, declared on trunk as a whole-symbol array), already emits clean on lr1g (origin/lr1g 0daba11a, Debug build: `dcl-ds A_00253; A_00253_F0 zoned(5:0) dim(200) inz(1); A_00253_G1000 char(10); end-ds;`, statements 5, emitted 5, failures 0). lr1g did not move the held-out declaration, so the held-out symbol is a scalar-path declaration that lr1g still refuses. Candidates ranked: 1. A standalone array whose image is no single element value (`ctdata`, or elements that differ): lr1g keeps "the image of a whole array" refused. Battery cases `lgd-t-*`. 2. A character field whose start value is longer than the twelve lines of lr1g, or one that has a byte that is not invariant (hexadecimal at twice its length). Battery cases `lgd-a-*` cover the trunk limit only. 3. A structure that the emitter declares whole as an array or a character field (no part proved at a byte other than 0) and that lr1g's array subfield rule does not reach. ## Loop-side note (not in this PR) `emit-families.awk` has no rule for the `checkNames` reasons "the name X is not declared" and "the name X names no symbol". A statement that `checkNames` fails keeps its proof text, so a runtime-call statement is classed "runtime or packed template statement / <routine>" and hides that its cause is a declaration. The coordinator gives these reasons their own label in the loop. lgd is rebased onto trunk 0daba11a (v0.1.487, lr1g merged); the `%DECH(` test of lr1g in `runtimeSummary` keeps its site s15. ## Battery lgd/decnum on v0.1.487: negative for the held-out pair The 24 captures (`captures/lgd-decnum`, the t-* table renamed `codes`: a name that starts with TAB is a table, RNF0752) emitted with a v0.1.487 Debug build. No case fires `checkNames s04`, and no declaration is refused: | cases | result | tokens | |---|---|---| | a-assign, a-char-tgt, a-editc, a-inth, a-whole | clean | none | | a-callp-int, a-call-int, a-callp-pk, t-callp, x-callp-plain | raw `CALL _QRNX_GET_DECIMAL_NUM(` | `runtimeSummary s03` | | t-elem, t-char | "the name A_00256 is declared without DIM and takes no index" | `checkNames s01` | | a-elem-tgt | `S254.4 = ...` (`S254.4: no type`): the target `arr(2)` | `statement s05` | | a-uns, a-dsply, x-uns-plain, d-* (6), t-assign | partial (the proof): `%UNS` is written `%DEC(F)`; `%DEC` of a char subfield at byte 0 of a structure with more subfields | none | | a-for | unresolved | none | Ruled out as the held-out declaration (each emits its declaration on v0.1.487): - a text start value of 193 characters, standalone or as a structure subfield (lr1g's lines); - the whole image of a `ctdata` array: declared `char(200)` with the image, not refused (it fails the statements with `checkNames s01`, another reason). What the oracle still requires: the symbol is refused by `declLine` or `structureLines` as longer than 100 bytes on v0.1.487, it is not a structure that `failUndeclared` reaches, and a statement names it in its emitted text. ## Second battery (proposal, not written) At most 12 cases, each one `%DEC`/`%INT` read of the symbol in an assignment (the form that emits clean above): 1. A start value with a byte that is not invariant (`characterLiteral` writes all of it in hexadecimal), 50, 90 and 150 bytes: `char(N) inz('... $ ...')` or `inz(x'..25..')`. 2. A text start value over twelve lines (more than about 1000 characters): `char(1200) inz(...)`. 3. A structure declared whole (no part at a byte other than 0): `%DEC` of the whole structure `ds` (`dcl-ds ds; a char(5) inz('00012'); b packed(9:2) inz(1); ...`), with a mixed image over 88 bytes, the `%dec(ds: 15: 0)` form. 4. A standalone array of distinct start values not from `ctdata` (`dim(40)` with a `pos` overlay start value, or `inz` per element through a structure `dim`). 5. A `varchar` with a long start value read by `%INT`, and a `based` field. ## Rule in this PR: a conversion as the argument of a procedure called as a statement `rpg_source_stmt.runtimeSummary` took an assignment or a RETURN as the final effect only. A procedure called as a statement (`callp showi(%int(...))`, `showi(...)`, `callp showp(%dec(...: 7: 0))` with a CONST packed parameter) ends in `CALLP P(...)`, and the summary refused it (`s03`). It now takes `CALLP ` too; the other gates are unchanged. The five public captures (lgd-a-callp-int, -call-int, -callp-pk, lgd-t-callp, lgd-x-callp-plain) then emit, for example, `SHOWP(%DEC(%SUBST(A_00258: 4: 5): 7: 0));` (lgd-t-callp still fails `checkNames s01` on its table). Test: `src/rpg_lgd_test.zig` (the CALLP summary, and `s03` still for a DSPLY final). The round trip of these captures is the coordinator's. Gates (Debug, base trunk 0daba11a, new lgd): `twins-diff` 811 groups, 789 recovered, no regression, none newly recovered (an emitter-only change); `emit-diff` no worse, no better, 571 clean of 773 on both (no committed twin has the form; the gain is on the lgd-decnum captures).
binjovi-bot manually merged commit 4cb712568f into trunk 2026-11-09 02:20:38 +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!771
No description provided.