verifier: account finite anonymous type sizes exactly

This commit is contained in:
dev committed 2026-10-09 13:26:17 +03:00
1 parent 03614c9bef
commit 111a3861f9
16 files changed
+226 -8

No files matched your search

@@ -35,7 +35,7 @@ Pending callback/return values remain ordinary SSA values, bounded by `max_value
All descriptors MUST be available before SSA inference: clause bindings name original parameters, the snapshot or result; parameter/result types come from the enclosing header, snapshot type from its helper header, and make explicitly names `checked<R,@p>`. Callback result types come from callback signatures. Budget calculation never dereferences an absent parameter or assumes predicate validity. Malformed bindings wait for their later stage; size and Copy/root-shape queries must be total on recursive/invalid types, with cycle detection and memoization, without invoking full type verification. Existing size accounting supplies the size-query precedent; the current recursive linearity query is not a safe pre-types substitute. An arbitrary body SSA binding is forbidden. Accounted size of checked<R,p> is size(R); predicate identity contributes no runtime member.
For this budget query, seed the existing intrinsically linear kinds and propagate linearity backwards through array elements, nominal struct/enum members and checked<R,@p>'s representation R to a least fixed point. Predicate identity contributes no edge. An invalid member cycle with no reachable linear leaf is non-linear (Copy for accounting); one reaching an owner or another linear leaf is linear. Direct borrow/root bindings remain in-place. This matches ordinary linearity on valid types and supplies a deterministic value on cycles, without accepting them. Preserve the existing accounted-size depth cutoff on invalid graphs rather than replacing a whole cyclic type's size with zero. Required candidate vectors include both kinds of cycle next to the frame limit: budget excess still reports E5101 first; otherwise the invalid cycle reaches the ordinary type rejection. These vectors are not among the fourteen executed baselines.
For this budget query, seed the existing intrinsically linear kinds and propagate linearity backwards through array elements, nominal struct/enum members and checked<R,@p>'s representation R to a least fixed point. Predicate identity contributes no edge. An invalid member cycle with no reachable linear leaf is non-linear (Copy for accounting); one reaching an owner or another linear leaf is linear. Direct borrow/root bindings remain in-place. This matches ordinary linearity on valid types and supplies a deterministic value on cycles, without accepting them. Use the corrected nominal-edge size-depth convention ([Q-058](open-questions.md#q-058--finite-anonymous-types-truncated-by-the-size-cycle-guard)); anonymous checked representation edges preserve that depth. Keep invalid-graph queries bounded rather than replacing a whole cyclic type's size with zero. Required candidate vectors include both kinds of cycle next to the frame limit: budget excess still reports E5101 first; otherwise the invalid cycle reaches the ordinary type rejection. These vectors are not among the fourteen executed baselines.
Two sequential clauses each materializing 600,000 bytes fit when L=S=0. One clause materializing both needs 1,200,000 and rejects. Snapshot 600,000 plus locals 500,000 rejects even with no temporary place. This rule does not infer lifetime reuse between arbitrary locals.