rpg_source.zig: settle() enforces the validator rules return and interface (also rpg_source_render_emit.zig, rpg_source_validate.zig) #790

Manually merged
binjovi-bot merged 2 commits from enforce2 into trunk 2026-11-12 01:10:59 +00:00
Owner

After blocks and loop_exit (enforce1), settle() now also changes the emit for two more rules. They run
only when refuseLate, refuseBlocks and refuseLoopExits flip nothing, on the current text; when anything
flips settle resets and renders again as before. It never runs dropUnreferenced, nameSymbols or
fitGlobals again.

  • return (refuseReturns, RNF5415): a procedure whose DCL-PI declares a return type and has no RETURN
    line.
    • The last refused RETURN of the procedure becomes returnPlaceholder (return VALUE; // SOURCERER-TODO return_value: ..., Entry.late_placeholder). It is a placeholder, never an emitted statement: the render
      subtracts it from emitted and counts it in placeholders.
    • With no refused RETURN, or a type that has no default value (returnPlaceholder answers null), the
      procedure is demoted as translate does when the type of the return value is not proved: its return type
      is dropped (dcl-pi *n;), its DCL-PROC becomes a failure line, and every emitted statement that calls it
      (validate.calls, now pub) becomes a failure line. The reasons end (validator: return); the DCL-PROC
      reason is the longest of five forms that still ends with it on the line cut at 100 characters.
  • interface (refuseInterfaces): a call that the validator finds to a procedure or prototype whose DCL-PI or
    DCL-PR holds a fail_pi_parameter_v1 or fail_pr_parameter_v1 line becomes a failure line ending
    (validator: interface). This is the late form of the loop at the end of declare.

condition_literal and bif_numeric are still reports. validator.counts after the re-render is the
validator on the final text. The columns and the mixed render are not read.

Measured, v0.1.506 build against this build (statements, emitted, failures, placeholders; validator counts):

program before after
asyncage 584, 320, 271, 17; return 9 584, 315, 272, 21; return 0
asyncdemo 621, 342, 286, 16; return 7 621, 339, 285, 20; return 0
asyncbg 597, 324, 279, 17; return 8 597, 320, 279, 21; return 0
asynccncl 608, 333, 282, 17; return 7 608, 330, 281, 21; return 0
asyncprom 619, 328, 297, 17; return 8 619, 324, 297, 21; return 0
asynctime 630, 350, 287, 17; return 6 630, 346, 288, 20; return 0

bif_numeric 1 and condition_literal 1 stay in each program, interface is 0 in all six. Of the 45 findings,
23 become a placeholder RETURN (four in each program, three in asynctime) and 22 demote a procedure (5, 3, 4,
3, 4, 3 in the order of the table); the emitted fall is that procedure's DCL-PROC and its callers. These
programs do not compile today.

The 852 committed twin emits differ in two rows, both with the matrix verdict failed:
lsel-for-arr-if-if (the call to RETHROW is a failure line, emitted 19 to 18, failures 13 to 14) and
return-switch-utf8-stripped (WORK drops int(10) and its DCL-PROC is a failure line, emitted 3 to 2,
failures 4 to 5). Every other emit is byte-identical, so no matching twin changes.

Tests: src/rpg_source_enforce2_test.zig.

Gate (coordinator, base v0.1.506)

  • dev emits p1-p5 same; L10-test unchanged; committed twins: only lsel-for-arr-if-if and return-switch-utf8-stripped change, both matrix verdict failed.
  • 87 standing captures: 12 changed, each one emitted -N / failures +N, each new failure line ends (validator: return) or (validator: interface). The six Async programs and six others (lsel-for-arr-if-if, lsel-for-arr-if-sel, lext-ptr-ret-null-c, lpar-lk-const-read, lpar-lk-set-second, lpar-lk-two-same). Host round trip of those six under v0.1.506: all six failed compile_failed already, so no host-matching case changes.
  • agree: suspect 94 -> 93, conflict 0, params_wrong 24, decl_missing 87, decl_extra 31.
  • gate FAIL lists exactly those 12 emitted/failure moves (intended: refused text that could not compile).
After `blocks` and `loop_exit` (enforce1), `settle()` now also changes the emit for two more rules. They run only when `refuseLate`, `refuseBlocks` and `refuseLoopExits` flip nothing, on the current text; when anything flips `settle` resets and renders again as before. It never runs `dropUnreferenced`, `nameSymbols` or `fitGlobals` again. - `return` (`refuseReturns`, RNF5415): a procedure whose DCL-PI declares a return type and has no RETURN line. - The last refused RETURN of the procedure becomes `returnPlaceholder` (`return VALUE; // SOURCERER-TODO return_value: ...`, `Entry.late_placeholder`). It is a placeholder, never an emitted statement: the render subtracts it from `emitted` and counts it in `placeholders`. - With no refused RETURN, or a type that has no default value (`returnPlaceholder` answers null), the procedure is demoted as `translate` does when the type of the return value is not proved: its return type is dropped (`dcl-pi *n;`), its DCL-PROC becomes a failure line, and every emitted statement that calls it (`validate.calls`, now `pub`) becomes a failure line. The reasons end `(validator: return)`; the DCL-PROC reason is the longest of five forms that still ends with it on the line cut at 100 characters. - `interface` (`refuseInterfaces`): a call that the validator finds to a procedure or prototype whose DCL-PI or DCL-PR holds a `fail_pi_parameter_v1` or `fail_pr_parameter_v1` line becomes a failure line ending `(validator: interface)`. This is the late form of the loop at the end of `declare`. `condition_literal` and `bif_numeric` are still reports. `validator.counts` after the re-render is the validator on the final text. The columns and the mixed render are not read. Measured, v0.1.506 build against this build (statements, emitted, failures, placeholders; `validator` counts): | program | before | after | |---|---|---| | asyncage | 584, 320, 271, 17; return 9 | 584, 315, 272, 21; return 0 | | asyncdemo | 621, 342, 286, 16; return 7 | 621, 339, 285, 20; return 0 | | asyncbg | 597, 324, 279, 17; return 8 | 597, 320, 279, 21; return 0 | | asynccncl | 608, 333, 282, 17; return 7 | 608, 330, 281, 21; return 0 | | asyncprom | 619, 328, 297, 17; return 8 | 619, 324, 297, 21; return 0 | | asynctime | 630, 350, 287, 17; return 6 | 630, 346, 288, 20; return 0 | `bif_numeric` 1 and `condition_literal` 1 stay in each program, `interface` is 0 in all six. Of the 45 findings, 23 become a placeholder RETURN (four in each program, three in asynctime) and 22 demote a procedure (5, 3, 4, 3, 4, 3 in the order of the table); the emitted fall is that procedure's DCL-PROC and its callers. These programs do not compile today. The 852 committed twin emits differ in two rows, both with the matrix verdict `failed`: `lsel-for-arr-if-if` (the call to RETHROW is a failure line, emitted 19 to 18, failures 13 to 14) and `return-switch-utf8-stripped` (WORK drops `int(10)` and its DCL-PROC is a failure line, emitted 3 to 2, failures 4 to 5). Every other emit is byte-identical, so no matching twin changes. Tests: `src/rpg_source_enforce2_test.zig`. ## Gate (coordinator, base v0.1.506) - dev emits p1-p5 same; L10-test unchanged; committed twins: only `lsel-for-arr-if-if` and `return-switch-utf8-stripped` change, both matrix verdict `failed`. - 87 standing captures: 12 changed, each one emitted -N / failures +N, each new failure line ends `(validator: return)` or `(validator: interface)`. The six Async programs and six others (lsel-for-arr-if-if, lsel-for-arr-if-sel, lext-ptr-ret-null-c, lpar-lk-const-read, lpar-lk-set-second, lpar-lk-two-same). Host round trip of those six under v0.1.506: all six `failed compile_failed` already, so no host-matching case changes. - agree: suspect 94 -> 93, conflict 0, params_wrong 24, decl_missing 87, decl_extra 31. - gate FAIL lists exactly those 12 emitted/failure moves (intended: refused text that could not compile).
sean force-pushed enforce2 from a192c85fed
Some checks reported errors
binjovi/ci A newer source or plan superseded this Build
to 48ca246dbf
All checks were successful
binjovi/ci Binjovi completed the frozen plan
2026-11-12 01:00:36 +00:00
Compare
binjovi-bot manually merged commit 48ca246dbf into trunk 2026-11-12 01:10:59 +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!790
No description provided.