END-PROC claims the default initializers of local pointers and signed 1-, 2- and 8-byte integers, and %LEN(%TRIMR(F)), %LEN(%TRIML(F)) are a trim unit #801

Manually merged
binjovi-bot merged 1 commit from lend into trunk 2026-11-14 15:51:07 +00:00
Owner

END-PROC claims the default initializers of local pointers and signed 1-, 2- and 8-byte integers, and %LEN(%TRIMR(F)), %LEN(%TRIML(F)) are a trim unit

Battery lend/endproc-trimr (24 public cases, captured 2026-11-14), written to
decide whether the unclaimed store 27 K; 37 S 0 N of the END-PROC of seven
public programs came from the EXTPGM prototype of a main(m) procedure or from a
named activation group. It came from neither.

The END-PROC (rpg_end.zig, rpg_initialization.zig).
The last statement of a subprocedure holds the out-of-line initialization
segment of its automatic variables. N of 37 S 0 N is a type index, not a
byte count. The stores that Scan.at left unclaimed were the defaults of
standalone locals:

  • dcl-s p pointer; is 27 K; 37 S 0 T: K the null literal, S a 16-byte
    pointer of the procedure, T the 16-byte pointer type (ossile 5 and 6, the
    implicit ptr of the ACCESS twin, two pointers of AOC). New
    initializers.localPointerNull, rule local_pointer_store_v1, in the segment.
    An explicit inz(*null) is the memset form that nullFill claimed already
    (lend-c07).
  • int(3), int(5) and int(20) are the same pair with a signed type of 1, 2
    and 8 bytes (bluemoon 1 i int(5), AOC answer int(20)). New
    initializers.localSignedStore (the 4-byte store keeps its callers, the
    static initialization and the closing, unchanged), rule integer_store_v1,
    automatic variables in the segment only.

lend-c01 to c05 and c08 carry the same store with and without the prototype
(main(m) against none), with return;, with a named, *new and *caller
activation group; lend-c06 (prototype, no local) recovered before the change.
Prototype, return and activation group change nothing.

Not claimed. The default of a local varchar(n) is a zero fill of n + 2 bytes
(33 F; 113 T 2; 27 0; 76 4; 78 4; 27 L; 97 0 3 10 0; 3, lend-c13). It stays
open on purpose: the declaration emitter types a local varchar only when a
varying assignment proves it (the AOC programs: varchar(100)), and declares
lend-c13 (a = 'x') as char(102). Claiming the fill without that proof would
turn a refusal into wrong text with no failure line. The three varchar locals of
each AOC program keep their END-PROC open for this reason. The next change is a
fill fact that the declaration emitter reads as a varchar.

The trim (rpg_trim.zig, rpg_eval.zig, rpg_source.zig).
unit (%LEN(%TRIM(F))) took only the two-loop form. It now takes the one-loop
forms that halves already reads: %LEN(%TRIMR(F)) (34 operations from 35 P,
lend-a01, a04) and %LEN(%TRIML(F)) (23 operations, lend-a03). The two size
guards (trailing: 42, leading: 30) were larger than the units and refused the
unit when the statement ended soon after it. New synthetic operations
op_triml_length and op_trimr_length carry the kind to the statement reader.
The emitter now accepts %TRIMR and %TRIML as built-in names (lend-a08
s = %trimr(c) into a char field recovers, the unit was proved before).

Not done. v += %trimr(c), v = %trimr(c) and v += %trim(c) into a varchar
(lend-a05, a06, a07, a09) stay open: the control %trim fails the same way, so the
gap is the varchar append consumer and not the trailing unit.

Probes adopted: lend-c01, c02, c03, c04, c06, c07, c08, c10, c11, c12, c13, c14,
c15, lend-a01, a02, a03, a04, a08 (SC-ILE/EXPERIMENTS). The test file is
src/rpg_lend_test.zig. rpg_end_source_test.zig no longer lists the ACCESS twin
statement 2500 as open: its one open operation was the implicit local pointer.

Gate (host round trips, base ~/bin/sourcerer v0.1.517)

params_wrong   base=15 head=15
decl_missing   base=82 head=82
decl_extra     base=27 head=27
type_unmarked  base=51 head=51
== f. host round trips (both binaries)
cases to round-trip: 23
dev5/p3                                            base=different head=different
dev5/p4                                            base=different head=different
dev5/p5                                            base=match head=match
l10-scout2b/l10-danlong005-openrpg/l10-danlong005-openrpg-1 base=match head=match
l10-scout2b/l10-danlong005-openrpg/l10-danlong005-openrpg-4 base=match head=match
l10-scout2b/l10-danlong005-openrpg/l10-danlong005-openrpg-5 base=match head=match
lend-endproc-trimr/lend-a01-len-trimr-loc          base=different head=match
lend-endproc-trimr/lend-a02-len-trim-loc           base=match head=match
lend-endproc-trimr/lend-a03-len-triml-loc          base=different head=match
lend-endproc-trimr/lend-a04-len-trimr-glob         base=different head=match
lend-endproc-trimr/lend-a08-char-trimr             base=different head=match
lend-endproc-trimr/lend-c01-main-pr-ptr            base=different head=different
lend-endproc-trimr/lend-c02-main-nopr-ptr          base=match head=match
lend-endproc-trimr/lend-c03-main-pr-ptr-ret        base=different head=different
lend-endproc-trimr/lend-c04-main-pr-ptr-grp        base=different head=different
lend-endproc-trimr/lend-c06-main-pr-nolocal        base=different head=different
lend-endproc-trimr/lend-c07-main-pr-ptr-inz        base=different head=different
lend-endproc-trimr/lend-c08-sub-ptr                base=match head=match
lend-endproc-trimr/lend-c10-sub-int20              base=match head=match
lend-endproc-trimr/lend-c11-sub-int5               base=match head=match
lend-endproc-trimr/lend-c12-sub-int3               base=match head=match
lend-endproc-trimr/lend-c14-bm-named               base=match head=match
lend-endproc-trimr/lend-c15-bm-new                 base=match head=match
gate: PASS
# END-PROC claims the default initializers of local pointers and signed 1-, 2- and 8-byte integers, and `%LEN(%TRIMR(F))`, `%LEN(%TRIML(F))` are a trim unit Battery `lend/endproc-trimr` (24 public cases, captured 2026-11-14), written to decide whether the unclaimed store `27 K; 37 S 0 N` of the END-PROC of seven public programs came from the EXTPGM prototype of a `main(m)` procedure or from a named activation group. It came from neither. **The END-PROC (`rpg_end.zig`, `rpg_initialization.zig`).** The last statement of a subprocedure holds the out-of-line initialization segment of its automatic variables. `N` of `37 S 0 N` is a type index, not a byte count. The stores that `Scan.at` left unclaimed were the defaults of standalone locals: - `dcl-s p pointer;` is `27 K; 37 S 0 T`: K the null literal, S a 16-byte pointer of the procedure, T the 16-byte pointer type (ossile 5 and 6, the implicit `ptr` of the ACCESS twin, two pointers of AOC). New `initializers.localPointerNull`, rule `local_pointer_store_v1`, in the segment. An explicit `inz(*null)` is the memset form that `nullFill` claimed already (lend-c07). - `int(3)`, `int(5)` and `int(20)` are the same pair with a signed type of 1, 2 and 8 bytes (bluemoon 1 `i int(5)`, AOC `answer int(20)`). New `initializers.localSignedStore` (the 4-byte `store` keeps its callers, the static initialization and the closing, unchanged), rule `integer_store_v1`, automatic variables in the segment only. lend-c01 to c05 and c08 carry the same store with and without the prototype (`main(m)` against none), with `return;`, with a named, `*new` and `*caller` activation group; lend-c06 (prototype, no local) recovered before the change. Prototype, return and activation group change nothing. **Not claimed.** The default of a local `varchar(n)` is a zero fill of n + 2 bytes (`33 F; 113 T 2; 27 0; 76 4; 78 4; 27 L; 97 0 3 10 0; 3`, lend-c13). It stays open on purpose: the declaration emitter types a local varchar only when a varying assignment proves it (the AOC programs: `varchar(100)`), and declares lend-c13 (`a = 'x'`) as `char(102)`. Claiming the fill without that proof would turn a refusal into wrong text with no failure line. The three varchar locals of each AOC program keep their END-PROC open for this reason. The next change is a fill fact that the declaration emitter reads as a varchar. **The trim (`rpg_trim.zig`, `rpg_eval.zig`, `rpg_source.zig`).** `unit` (`%LEN(%TRIM(F))`) took only the two-loop form. It now takes the one-loop forms that `halves` already reads: `%LEN(%TRIMR(F))` (34 operations from `35 P`, lend-a01, a04) and `%LEN(%TRIML(F))` (23 operations, lend-a03). The two size guards (`trailing`: 42, `leading`: 30) were larger than the units and refused the unit when the statement ended soon after it. New synthetic operations `op_triml_length` and `op_trimr_length` carry the kind to the statement reader. The emitter now accepts `%TRIMR` and `%TRIML` as built-in names (lend-a08 `s = %trimr(c)` into a char field recovers, the unit was proved before). **Not done.** `v += %trimr(c)`, `v = %trimr(c)` and `v += %trim(c)` into a varchar (lend-a05, a06, a07, a09) stay open: the control `%trim` fails the same way, so the gap is the varchar append consumer and not the trailing unit. Probes adopted: lend-c01, c02, c03, c04, c06, c07, c08, c10, c11, c12, c13, c14, c15, lend-a01, a02, a03, a04, a08 (SC-ILE/EXPERIMENTS). The test file is `src/rpg_lend_test.zig`. `rpg_end_source_test.zig` no longer lists the ACCESS twin statement 2500 as open: its one open operation was the implicit local pointer. ## Gate (host round trips, base ~/bin/sourcerer v0.1.517) ``` params_wrong base=15 head=15 decl_missing base=82 head=82 decl_extra base=27 head=27 type_unmarked base=51 head=51 == f. host round trips (both binaries) cases to round-trip: 23 dev5/p3 base=different head=different dev5/p4 base=different head=different dev5/p5 base=match head=match l10-scout2b/l10-danlong005-openrpg/l10-danlong005-openrpg-1 base=match head=match l10-scout2b/l10-danlong005-openrpg/l10-danlong005-openrpg-4 base=match head=match l10-scout2b/l10-danlong005-openrpg/l10-danlong005-openrpg-5 base=match head=match lend-endproc-trimr/lend-a01-len-trimr-loc base=different head=match lend-endproc-trimr/lend-a02-len-trim-loc base=match head=match lend-endproc-trimr/lend-a03-len-triml-loc base=different head=match lend-endproc-trimr/lend-a04-len-trimr-glob base=different head=match lend-endproc-trimr/lend-a08-char-trimr base=different head=match lend-endproc-trimr/lend-c01-main-pr-ptr base=different head=different lend-endproc-trimr/lend-c02-main-nopr-ptr base=match head=match lend-endproc-trimr/lend-c03-main-pr-ptr-ret base=different head=different lend-endproc-trimr/lend-c04-main-pr-ptr-grp base=different head=different lend-endproc-trimr/lend-c06-main-pr-nolocal base=different head=different lend-endproc-trimr/lend-c07-main-pr-ptr-inz base=different head=different lend-endproc-trimr/lend-c08-sub-ptr base=match head=match lend-endproc-trimr/lend-c10-sub-int20 base=match head=match lend-endproc-trimr/lend-c11-sub-int5 base=match head=match lend-endproc-trimr/lend-c12-sub-int3 base=match head=match lend-endproc-trimr/lend-c14-bm-named base=match head=match lend-endproc-trimr/lend-c15-bm-new base=match head=match gate: PASS ```
The unclaimed store of the END-PROC of seven public programs is the default
initialization of a standalone local, not the EXTPGM prototype of a main
procedure or a named activation group (battery lend/endproc-trimr).

- rpg_initialization: localPointerNull (27 K; 37 S 0 T, K the null literal) and
  localSignedStore (the same pair with a signed 1-, 2- or 8-byte type, automatic
  variables only); the 4-byte store keeps its callers.
- rpg_end: both in the initialization segment.
- rpg_trim: unit takes the one-loop forms %LEN(%TRIMR(F)) and %LEN(%TRIML(F));
  the size guards of leading and trailing match the units; two synthetic
  length operations carry the kind.
- rpg_source: %TRIMR and %TRIML are built-in names of the emitter.
- A local varchar default (zero fill) stays open: its declaration is not typed
  without a varying assignment.
sean force-pushed lend from f71c198d6d
Some checks reported errors
binjovi/ci A newer source or plan superseded this Build
to 2f8c685162
All checks were successful
binjovi/ci Binjovi completed the frozen plan
2026-11-14 15:36:22 +00:00
Compare
binjovi-bot manually merged commit 2f8c685162 into trunk 2026-11-14 15:51:07 +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!801
No description provided.