cli: validate structural source type positions before AIR

This commit is contained in:
dev committed 2026-10-07 23:54:55 +03:00
1 parent 5f76e92ff3
commit caf3b86e80
48 files changed
+423 -33

No files matched your search

+7 -1
View File
@@ -313,4 +313,10 @@ Clarify whether `let`/`move` aliases and rebinding of a scope name are permitted
Read-only P6-2 review reproduced `module nested fn f(p: ref<ref<u64>>) -> void effects [] {} fn main() -> void effects [] {}` on the preceding compiler. It reaches the verifier and reports E1001 (`position: borrowed`, `found: ref<u64>`) at the source function. Spec 15 §10 requires errors fully decided by source types to be reported as E7xxx, and the AIR type-position rule already rejects this referent. This is an existing frontend validation gap, independent of dereferenced argument parsing; no new borrow semantics is proposed.
Audit source type-position checks against the existing verifier rules, including unused generic signatures where a restriction is already known. Add valid/rejected source fixtures and report E7005 at the offending type annotation before generating invalid AIR; preserve the AIR rules and determine compatibility for existing source diagnostic consumers. The extent beyond this reproduced nested-borrow case is unverified.
**Resolved for structural positions (spec 15 §10):** frontend annotation checks use the verifier's pure type-position predicates. Parameters, returns, fields, payloads, nested constructors, local annotations and known unused generic/static-contract headers reject E7005 at the invalid constructor with `position` and `type_constructor`; unknown parameter restrictions are checked after substitution. Graph-content properties retain E2111. Existing AIR acceptance, diagnostics and runtime rules are unchanged. Invalid source types formerly rejected by E1001 or a feature diagnostic now reject earlier; known invalid unused generic headers and annotations previously skipped by lowering also reject. Generic argument diagnostics may have more precise coordinates and different fields. Property checks beyond structural positions are separate (Q-043); this does not establish complete source type-check coverage.
## Q-043 — Copy content validation for source dynamic owning arrays
Read-only review after Q-042 reproduced `module nested fn unused(p: own_array<own<u64>>) -> void effects [] { trap; } fn main() -> void effects [] {}`. It reaches the AIR verifier with E1001, `dynamic heap arrays require Copy content`. Spec 03 §25 requires Copy content for `own_array<T>`, and spec 15 §10 requires fully source-type-decided errors to be E7xxx. This is a content-property check, not a structural type position. Graph-content properties and Send/Share checks retain their separately specified verifier diagnostics.
Audit this source check, including nominal and substituted generic content, then add positive/rejected source tests and report E7005 before emitting invalid AIR. Preserve AIR's Copy predicate, type identity, allocation/cleanup rules and deterministic behavior. The extent beyond the reproduced signature is unverified.