cli: validate inferred allocation content before AIR

This commit is contained in:
dev committed 2026-10-08 10:31:10 +03:00
1 parent 1bbfed24a8
commit bc5412dadd
67 files changed
+607 -8

No files matched your search

+8
View File
@@ -338,3 +338,11 @@ Q-043 review reproduced `fn unused(p: ref<u64>) -> void effects [] { let a = [p,
Q-045 review reproduced `fn unused(heap: cap<mem.alloc>, p: ref<u64>) -> void effects [mem.alloc] { let a = own.new(p, heap) or trap; trap; }`: the inferred `own<ref<u64>>` reaches AIR E1001 in member position. Existing source annotations reject this under Q-042, but the constructor infers its content type from a value. Review identified analogous call paths in `own.pack`, `mutex.make` and graph allocation; those additional cases remain unverified.
Audit each constructor against its own existing content/position/property rules and diagnostic precedence before changing it. In particular, distinguish Copy-only construction, explicit linear transfer and graph-content E2111. Add source positives/rejections and stable E7xxx at fully source-decided errors, preserving provenance, effects/capabilities, outcomes and frozen AIR behavior. Do not apply one broad Copy restriction to every wrapper.
**Resolved (spec 15 §10):** inferred void/never content rejects E7005 before constructors form results or outcomes; never operands formerly reached a null-block panic, and void operands could produce malformed AIR/E7900. `own.new`, `region.new` and `region.array` use the verifier's exact Copy predicate on the completed nominal type snapshot, reporting `constraint: Copy` and `operation` at the value. `own.pack` rejects root borrows with `position: member` and `type_constructor`; complete linear values and allocation-failure recovery remain valid. Existing explicit-move checks run first. `own.array` retains its earlier Copy diagnostic, including void/never. Mutex element rules, graph properties and reserved transfers otherwise stay in the verifier: `own.pack(task)` retains E0006 task_transfer, and mutex endpoints retain E0006 channel_transfer. Copy-only constructors reject task content independently of that gate. Existing `island.alloc` precedence reports E1001 for root borrows through `iref<T>` positioning; root owners report E1001 without `linear_aggregates`, but E2111 when an owning aggregate declaration enables that feature in the module. Nominal values with owning members report E2111. This distinction depends on the feature header, not lexical block nesting, and remains with the verifier. No AIR acceptance, ownership/effect/capability rule, outcome, allocation/cleanup or deterministic interpreter behavior changes. Invalid source stops earlier; accepted canonical AIR is unchanged. This closes the audited constructor paths, not all source type-check completeness.
## Q-047 — Non-value operands outside inferred constructors
Q-046 review identified other uses of `never` that reach lowering with no current block. Independently reproduced: `module test.never_operand fn stop() -> never effects [] { trap; } fn main() -> u64 effects [] { return 1u64 + stop(); }` aborts while `Lowerer.binary` calls `def`/`emit` after `stop()` terminated the block. Review also reproduced ordinary call arguments and struct fields; their exact scope remains unverified. Q-046 guards constructor content only.
Audit non-value operands in ordinary calls, operators and aggregates against spec 15 before emission. Distinguish value-requiring positions from valid void statements and never-returning control flow. Add source rejection/acceptance and CLI tests, preserving evaluation order, explicit transfers, diagnostics and canonical AIR for valid source. A source program MUST NOT cause a lowering panic; do not infer a new divergence/coercion rule from implementation behavior.