rpg_subroutines.zig: a subroutine that holds a FOR loop is a valid routine (EXSR of it recovers) #761

Manually merged
binjovi-bot merged 2 commits from lcf2 into trunk 2026-11-08 12:53:09 +00:00
Owner

rpg_subroutines.zig: a subroutine that holds a FOR loop is a valid routine (EXSR of it recovers)

Predicted mechanism (before the rule). The address-push arm of rpg_eval.step (operation 33) declines a
symbol that is not data: a label pointer (kind 22, a return point). That is the second site of the arm, and it
is a fallback label in every public twin that reaches it. The return point is stored by a typed construct that
a recognizer owns, and when the recognizer refuses, the evaluator reports the first operation it cannot read:

  • OPS/dspf-io statement 20 (exsr load): 33 505; 35 256; 18 315; 15 352 2 is the EXSR call
    (rpg_subroutines.Proof.callBody). The call is valid only when its routine is valid, and load was refused
    by validRegion: its for i = 1 to 3 counts through a local call (33 512; 35 305; 15 383 2; 34 255 0; 35 306; 27 305; 19; 15 384 2), and validRegion rejects every 19 that is not the routine's own return or a
    known I/O call, and every return point that enters the region. So the EXSR, the BEGSR marker and the ENDSR
    of the routine all fell back to raw operations, and the first one reported was operation 33.
  • ACCESS (33 436; 35 299 in the init of a linear-main module) and DSPLY/error statement 1100
    (33 560; 37 46 64 9 in dsply(e)) store a return point of a compiler construct that no recognizer reads
    (the init template of a linear main; the (E) form of the DSPLY proof). Unchanged here; not control flow.
  • The r7h-prt-* twins fail the cycle start of a printer file at the same first operation (the printer emitter
    gap), and the held-out side cannot be told from the tokens alone.

Rule (rpg_subroutines.inProvedFor): in validRegion, an operation 19 and a typed return point whose target
lie in the head or the end statement of a FOR loop that rpg_loops.recover proves completely are part of that
proof and are accepted. The loop proof already checks every edge and return point of the loop.

Result: dspf-io statements 20, 34 (BEGSR) and 43 (ENDSR) recover and the routine renders BEGSR SR315 ... ENDSR;
the remaining stop of the twin is operation 15 of %CHAR(i) (statement 37). Test:
src/rpg_qual_cond_test.zig (red on trunk 435ab27f, green here).

lcf-qc-* twins (no-regression set)

Twenty of the 24 captured twins are adopted (lcfqc-*; the four that need the empty-IF rule of #758 or a date
compare are left out). On the Debug build of #758 none of the 24 stops at control_flow. Without #758 only
empty-c3 and empty-plain do (condition_boundary), which names the empty body, not the subfield, as the
cause. The other stops are outside control flow: packed and zoned compared with a literal
(type_inference / decimal_positions: if-p0, if-p3, if-z0, if-z3, and-cz, or-cp, nested) and a
date subfield compared with a date field (if-d0, if-d3: call / classification).

# rpg_subroutines.zig: a subroutine that holds a FOR loop is a valid routine (EXSR of it recovers) Predicted mechanism (before the rule). The address-push arm of `rpg_eval.step` (operation 33) declines a symbol that is not data: a label pointer (kind 22, a return point). That is the second site of the arm, and it is a fallback label in every public twin that reaches it. The return point is stored by a typed construct that a recognizer owns, and when the recognizer refuses, the evaluator reports the first operation it cannot read: - `OPS/dspf-io` statement 20 (`exsr load`): `33 505; 35 256; 18 315; 15 352 2` is the EXSR call (`rpg_subroutines.Proof.callBody`). The call is valid only when its routine is valid, and `load` was refused by `validRegion`: its `for i = 1 to 3` counts through a local call (`33 512; 35 305; 15 383 2; 34 255 0; 35 306; 27 305; 19; 15 384 2`), and `validRegion` rejects every `19` that is not the routine's own return or a known I/O call, and every return point that enters the region. So the EXSR, the BEGSR marker and the ENDSR of the routine all fell back to raw operations, and the first one reported was operation 33. - `ACCESS` (`33 436; 35 299` in the init of a linear-main module) and `DSPLY/error` statement 1100 (`33 560; 37 46 64 9` in `dsply(e)`) store a return point of a compiler construct that no recognizer reads (the init template of a linear main; the (E) form of the DSPLY proof). Unchanged here; not control flow. - The r7h-prt-* twins fail the cycle start of a printer file at the same first operation (the printer emitter gap), and the held-out side cannot be told from the tokens alone. Rule (`rpg_subroutines.inProvedFor`): in `validRegion`, an operation `19` and a typed return point whose target lie in the head or the end statement of a FOR loop that `rpg_loops.recover` proves completely are part of that proof and are accepted. The loop proof already checks every edge and return point of the loop. Result: dspf-io statements 20, 34 (BEGSR) and 43 (ENDSR) recover and the routine renders `BEGSR SR315 ... ENDSR`; the remaining stop of the twin is operation 15 of `%CHAR(i)` (statement 37). Test: `src/rpg_qual_cond_test.zig` (red on trunk `435ab27f`, green here). ## lcf-qc-* twins (no-regression set) Twenty of the 24 captured twins are adopted (`lcfqc-*`; the four that need the empty-IF rule of #758 or a date compare are left out). On the Debug build of #758 none of the 24 stops at control_flow. Without #758 only `empty-c3` and `empty-plain` do (condition_boundary), which names the empty body, not the subfield, as the cause. The other stops are outside control flow: packed and zoned compared with a literal (type_inference / decimal_positions: `if-p0`, `if-p3`, `if-z0`, `if-z3`, `and-cz`, `or-cp`, `nested`) and a date subfield compared with a date field (`if-d0`, `if-d3`: call / classification).
binjovi-bot manually merged commit d389f50657 into trunk 2026-11-08 12:53:09 +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!761
No description provided.