cli: check inferred array elements before AIR

This commit is contained in:
dev committed 2026-10-08 09:26:33 +03:00
1 parent cfbe01a16f
commit 1bbfed24a8
40 files changed
+337 -9

No files matched your search

+7 -1
View File
@@ -331,4 +331,10 @@ Audit the existing classification/layout ordering and shared-query cost with cou
Q-043 review reproduced `fn unused(p: ref<u64>) -> void effects [] { let a = [p, p]; }`: the source array literal reaches AIR type checking with E1001 because borrows cannot be stored as array elements. Q-042 validates annotations; an inferred literal has none. Q-043 now rejects that array as a repeated `own.array` value, but constructing it without that operation remains a separate source validation gap.
Audit inferred list/repeat literals against existing member-position and Copy-duplication rules, including nested arrays and nominal values. Add source positives/rejections with E7005 at the offending source value while preserving explicit moves in fixed linear arrays, borrow provenance and frozen AIR semantics. Scope beyond this reproduced literal remains unverified.
**Resolved (spec 15 §5/§10):** each inferred list/repeat element is checked before array construction. Borrows retain E7006 `invalid_literal`; forbidden member constructors (including void/never/task) report E7005 with `position` and `type_constructor`. Repeated elements use the verifier's exact Copy predicate and report E7005 with `constraint: Copy` and `type_constructor: array`. Lists preserve explicit linear moves, E7003 for missing moves and verifier E2002 for duplicates. Element validity precedes expected-type agreement with or without an annotation; an invalid annotation itself still rejects first. Thus some earlier mismatches/ownership-wrapper errors are replaced by a diagnostic at the first invalid element. The Q-043 `own.array` check remains a second line of defense. AIR acceptance, verifier/runtime rules and valid-source canonical output are unchanged. Wrapper construction from inferred values is separate (Q-046).
## Q-046 — Inferred content types in ownership and graph constructors
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.