rpg_shape.zig: an IF with an empty body is its own boundary (touches rpg_statements.zig) #758

Manually merged
binjovi-bot merged 4 commits from lcf into trunk 2026-11-08 11:52:06 +00:00
Owner

rpg_shape.zig: an IF with an empty body is its own boundary (touches rpg_statements.zig)

Predicted mechanism (written before the rule). if R.m = 'Y'; endif; (SC-ILE/EXPERIMENTS lcf-cond1, the
dictionary battery dict-cond1, statement 18) stopped at control_flow / condition_boundary on the false
label and at value_flow / operation_semantics on operation 33. Operation 33 (33 256; 27 431; 62; 32 256 0 3, the address of the data structure plus the subfield offset) was not the cause: the same
read recovers as WHEN S256.10 = 'Y' in the SELECT of the same program. A condition statement that
the shape cannot give a boundary falls back to its raw operations, and the first operation without a
value rule, the pushed address, is then reported. The cause is the boundary:

  • A body statement defines the false label of its IF at its end, and forwardBoundary accepts the
    label when the next statement is the ENDIF marker (a codeless statement).
  • An IF with no body statement has no such statement: the compiler defines the label (15 329 2) at the
    end of the IF statement itself, and the ENDIF marker follows. conditionBoundary looks only at later
    statements, so the IF was refused, then the marker was read as the opener of a SELECT, and the block
    after it as a WHEN: every statement after the first empty IF of the program was wrong.

Rule (rpg_shape.ownBoundary): a condition statement is its own boundary when it defines the false label
of its condition jump, that jump is the only edge to the label in the procedure graph, and the next
statement is codeless. The IF then opens as usual and the existing ENDIF logic closes it at the marker.
The hook in rpg_statements.renderCondition replaces a line (net zero lines in rpg_statements.zig).

Result on the battery: all 26 statements of dict-cond1 emit with 0 failures (if, dow, dou,
select/when with a subfield of a qualified data structure, an indicator subfield, AND, NOT, *BLANKS);
2 statements stay partial at type_inference / decimal_positions (R.n = 3, zoned). Test:
src/rpg_empty_if_test.zig (red on trunk 1e322e1e, green here; mutations that add a second jump to the label
or make the marker not codeless refuse the IF).

Measured state of the other twins (no rule)

  • lr1-di-pk3, -pk5, -pk5-sub, -zd4: recovered since v0.1.462 by f8d81c5f (decimal-index FOR); the
    v0.1.459 leads are stale.

  • FLOW/lx-total: the cycle end proof (rpg_cycle.totals) requires 18 L right after the *TOTC PSDS
    store; the total calculation between them leaves detailEnd null, which gives both block_owner stops.
    rpg_loop_exits_test.zig pins that refusal. Not changed here.

  • MONITOR/limits: nested monitors and selected handlers (monitor_boundaries), partial by design.

  • Probe lcf-cond1 (dictionary capture dict-cond1).

lcf-qc-* battery (24 programs, qualified subfield in IF, WHEN, DOW, DOU, AND, OR, nested IF, ELSE, ELSEIF)

With this change none of the 24 stops at control_flow. Without it only empty-c3 and empty-plain
(a plain field, no data structure) do, so the cause is the empty body and not the subfield read. The other
stops are not control flow: a packed or zoned subfield compared with a literal stops at type_inference /
decimal_positions (if-p0, if-p3, if-z0, if-z3, and-cz, or-cp, nested: a family for a later lane)
and a date subfield compared with a date field stops at call / classification (if-d0, if-d3).

Gates

{"checks":{"net_statements":0},"census":{"statuses":{"recovered":645,"partial":0,"unresolved":0},"regressions":0,"newly_recovered":0},"golden":"golden floor 173 ceiling 0 <= dump 173/5/0","legend":"regenerated","emit":{"worse":[],"better":0,"newly_clean":1,"clean_delta":1,"base":493,"new":494},"twins":{"groups":749,"recovered":731,"regressions":[],"newly":1},"allgroups":{"regressions":[],"newly":[],"worse":[]},"full_check":{"exit":0,"seconds":1004}}
# rpg_shape.zig: an IF with an empty body is its own boundary (touches rpg_statements.zig) Predicted mechanism (written before the rule). `if R.m = 'Y'; endif;` (SC-ILE/EXPERIMENTS lcf-cond1, the dictionary battery dict-cond1, statement 18) stopped at control_flow / condition_boundary on the false label and at value_flow / operation_semantics on operation 33. Operation 33 (`33 256; 27 431; 62; 32 256 0 3`, the address of the data structure plus the subfield offset) was not the cause: the same read recovers as `WHEN S256.10 = 'Y'` in the SELECT of the same program. A condition statement that the shape cannot give a boundary falls back to its raw operations, and the first operation without a value rule, the pushed address, is then reported. The cause is the boundary: - A body statement defines the false label of its IF at its end, and `forwardBoundary` accepts the label when the next statement is the ENDIF marker (a codeless statement). - An IF with no body statement has no such statement: the compiler defines the label (`15 329 2`) at the end of the IF statement itself, and the ENDIF marker follows. `conditionBoundary` looks only at later statements, so the IF was refused, then the marker was read as the opener of a SELECT, and the block after it as a WHEN: every statement after the first empty IF of the program was wrong. Rule (`rpg_shape.ownBoundary`): a condition statement is its own boundary when it defines the false label of its condition jump, that jump is the only edge to the label in the procedure graph, and the next statement is codeless. The IF then opens as usual and the existing ENDIF logic closes it at the marker. The hook in `rpg_statements.renderCondition` replaces a line (net zero lines in `rpg_statements.zig`). Result on the battery: all 26 statements of dict-cond1 emit with 0 failures (`if`, `dow`, `dou`, `select`/`when` with a subfield of a qualified data structure, an indicator subfield, AND, NOT, `*BLANKS`); 2 statements stay partial at type_inference / decimal_positions (`R.n = 3`, zoned). Test: `src/rpg_empty_if_test.zig` (red on trunk `1e322e1e`, green here; mutations that add a second jump to the label or make the marker not codeless refuse the IF). ## Measured state of the other twins (no rule) - `lr1-di-pk3`, `-pk5`, `-pk5-sub`, `-zd4`: recovered since v0.1.462 by `f8d81c5f` (decimal-index FOR); the v0.1.459 leads are stale. - `FLOW/lx-total`: the cycle end proof (`rpg_cycle.totals`) requires `18 L` right after the `*TOTC` PSDS store; the total calculation between them leaves `detailEnd` null, which gives both block_owner stops. `rpg_loop_exits_test.zig` pins that refusal. Not changed here. - `MONITOR/limits`: nested monitors and selected handlers (`monitor_boundaries`), partial by design. - Probe `lcf-cond1` (dictionary capture dict-cond1). ## lcf-qc-* battery (24 programs, qualified subfield in IF, WHEN, DOW, DOU, AND, OR, nested IF, ELSE, ELSEIF) With this change none of the 24 stops at control_flow. Without it only `empty-c3` and `empty-plain` (a plain field, no data structure) do, so the cause is the empty body and not the subfield read. The other stops are not control flow: a packed or zoned subfield compared with a literal stops at type_inference / decimal_positions (`if-p0`, `if-p3`, `if-z0`, `if-z3`, `and-cz`, `or-cp`, `nested`: a family for a later lane) and a date subfield compared with a date field stops at call / classification (`if-d0`, `if-d3`). ## Gates ``` {"checks":{"net_statements":0},"census":{"statuses":{"recovered":645,"partial":0,"unresolved":0},"regressions":0,"newly_recovered":0},"golden":"golden floor 173 ceiling 0 <= dump 173/5/0","legend":"regenerated","emit":{"worse":[],"better":0,"newly_clean":1,"clean_delta":1,"base":493,"new":494},"twins":{"groups":749,"recovered":731,"regressions":[],"newly":1},"allgroups":{"regressions":[],"newly":[],"worse":[]},"full_check":{"exit":0,"seconds":1004}} ```
sean force-pushed lcf from 4e1d4d762f
All checks were successful
binjovi/ci Binjovi completed the frozen plan
to 92c1ca45a3
All checks were successful
binjovi/ci Binjovi completed the frozen plan
2026-11-08 11:43:03 +00:00
Compare
binjovi-bot manually merged commit 92c1ca45a3 into trunk 2026-11-08 11:52:06 +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!758
No description provided.