rpg_source.zig: settle() enforces the validator rules blocks and loop_exit (also rpg_source_decl_emit.zig, rpg_source_render_emit.zig) #789
Loading…
Reference in a new issue
No description provided.
Delete branch "enforce1"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
settle()read the finished text and only reported. For the rulesblocksandloop_exitit nowchanges the emit, in this order, until nothing flips:
refuseLate: a failure line (fail_statement_v1,fail_statement_long_v1) whose entry is still code(the render refused it, a long statement) becomes a failed entry with the reason and the form of
that line, so the line is written again as it was. A new
Entry.fail_formcarries the form.refuseBlocks:balanceruns again (balanceBlocks, repeated until it flips nothing) over the entries,so the remaining parts of a block that now holds a failure line (an ELSE, ELSEIF, WHEN, OTHER,
ON-ERROR, END) become failure lines whose text ends
(validator: blocks)(RNF5141, RNF5142).The statements inside the block stay.
refuseLoopExits: a LEAVE or ITER that the validator finds with no emitted DOW, DOU or FOR around itbecomes a failure line whose text ends
(validator: loop_exit)(RNF5232). Run only when the first twoflip nothing, on the current text.
When anything flipped,
settleresets as the short-names path does (trailer, counts,assumed,long_failures) and callsrenderagain with the same symbol names. It never runsdropUnreferenced,nameSymbolsorfitGlobalsagain.rpg_source_decl_emit.balanceis unchanged for its caller (text(its block is not whole));balanceBlocksis the same walk with the reason... (its block is not whole) (validator: blocks), cut so that the whole failure line fits 100 characters with its end. Columnsand mixed renders are not read. The rules
return,interface,condition_literalandbif_numericare still reports.
validator.countsafter the re-render is the validator on the final text.Measured, v0.1.505 build against this build (statements, emitted, failures;
validatorcounts):In each program the broken block is one ELSE and one ENDIF (for asyncage statements 79900 and 80200, whose
head is a failure line); each becomes a failure line, emitted falls by 2 and failures rise by 2, and
no other line of the emit changes (diff: those two lines and the summary line).
loop_exithas 0findings in the six programs and in the 824 emits of the committed twins, so its effect is proved
on synthetic entries only (
src/rpg_source_enforce1_test.zig); the requestrequests/enforce1/loop-exitasks for the compile. The emits of the 852 committed twin rows arebyte-identical to the v0.1.505 build (12
blocksfindings of the six programs: 0 now; the oneblocksfinding of a twin,
init-auto-char-heldout, is a DCL-PROC with no END-PROC, which no entry holds and whichstays a finding).
Known limit, not changed here: the validator counts any emitted loop around a LEAVE or ITER. A LEAVE
inside a refused inner loop that sits in an emitted outer loop is not refused.
Tests:
src/rpg_source_enforce1_test.zig.Gate (coordinator, base v0.1.505)
else;/endif;of a refused block, now failure lines ending(validator: blocks). These are the intended change (wrong text that cannot compile becomes a refusal); gate FAIL lists only these six.95697e59da644e983c95