cli: check inferred array elements before AIR
This commit is contained in:
1 parent
cfbe01a16f
commit
1bbfed24a8
40 files changed
+337
-9
No files matched your search
@@ -158,3 +158,5 @@ Q-023 whole-array arguments (DD-021, cl100k): Quick Reference 8,889 → 8,948 (+
|
||||
Q-042 structural type positions (cl100k): Quick Reference stays 8,948; other source docs 66,669 → 66,761 (+92), full source 75,617 → 75,709 (+0.12%). o200k groups are 8,984 / 66,965 / 75,949; Qwen2.5 9,226 / 68,398 / 77,624. AIR remains 184,628 bytes / 47,445 cl100k tokens; library/std.md is unchanged. Existing type-position predicates now reject invalid source annotations before AIR, including known unused generic headers, with structured E7005 fields at the constructor. No new concept, syntax, code, feature or verifier/runtime state is added. Earlier source diagnostic codes/fields may change; graph properties retain verifier diagnostics. No empirical MCC benefit is claimed.
|
||||
|
||||
Q-043 dynamic owning-array content (cl100k): Quick Reference stays 8,948; other source docs 66,761 → 66,827 (+66), full source 75,709 → 75,775 (+0.09%). o200k groups are 8,984 / 67,031 / 76,015; Qwen2.5 9,226 / 68,466 / 77,692. AIR remains 184,628 bytes / 47,445 cl100k tokens; library/std.md is unchanged. Existing Copy-content rules now reject annotations and repeated allocation values with structured E7005 before AIR, including known unused generic/static contracts and nominal contents. Unknown parameters defer to substitution; iref remains phantom. No new concept, syntax, code, feature or verifier/runtime state is added. Earlier invalid-source diagnostics and priority may change; graph-root properties retain verifier diagnostics. No empirical MCC benefit is claimed.
|
||||
|
||||
Q-045 inferred array literals (cl100k): Quick Reference stays 8,948; other source docs 66,827 → 66,906 (+79), full source 75,775 → 75,854 (+0.10%). o200k groups are 8,984 / 67,110 / 76,094; Qwen2.5 9,226 / 68,550 / 77,776. AIR remains 184,628 bytes / 47,445 cl100k tokens; library/std.md is unchanged. Existing member-position and Copy-repetition rules now reject invalid inferred elements before AIR, at the offending value. Lists retain explicit linear transfers; repeated borrows retain E7006 invalid_literal. No new concept, syntax, code, reason, feature or verifier/runtime state is added. Invalid-source diagnostic codes/priority may change; accepted canonical AIR is preserved. No empirical MCC benefit is claimed.
|
||||
@@ -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.
|
||||
@@ -253,3 +253,11 @@ Q-043/spec 15 §10 enforces the existing Copy-content requirement for source `ow
|
||||
The preserved invariant is that repeated dynamic heap arrays contain Copy values, so bulk release cannot destroy nested resources. AIR independently retains the same type/operation checks; allocation budgets, initialization, owner transfer, explicit release and deterministic interpreter behavior are unchanged. Valid Copy allocations run with explicit release; rejected annotations and repeated linear values report E7005 with `constraint` and `type_constructor`. Existing invalid-source codes/priority may change, including Copy violations preceding simultaneous layout errors. No syntax, code, feature, verifier/runtime state or evaluation input changes. Source bundle growth is recorded in docs/agent/README.md; P6-2 remains open.
|
||||
|
||||
Validation: full conformance 1,335/1,335; all 32 new fixtures also pass with per-instruction collection. Unit tests pass 128/128, including counted acyclic/cyclic diamond queries; the cyclic case failed before the cache correction. CLI integration passes 119 checks with exact annotations/value positions, nested package imports and source/AIR/hosted parity. Formatter passes 4,563 checks over 1,047 public files (1,039 parsed, eight existing syntax errors, 638 identical AIR outputs); source coverage remains 121/121. Comparison of all 1,017 preceding public sources preserves every check/lower result and all 631 successful canonical lowerings. No AIR verifier/runtime files change. Independent Claude review passes after checking shadowing, generic rotations, cache invalidation and the complete declaration snapshot used by the shared Copy predicate.
|
||||
|
||||
## P6-2 inferred array literals (2026-10-08)
|
||||
|
||||
Q-045/spec 15 §5/§10 applies the existing member-position rule to each inferred array element before construction and the exact verifier Copy predicate to repetitions. Borrow elements reject E7006 invalid_literal; forbidden constructors and non-Copy repeats reject E7005 at the value with structured fields. Element validity precedes expected-type agreement; annotation errors still reject first. Existing linear lists preserve explicit moves and complete-value transfer, including missing-move and duplicate-owner diagnostics.
|
||||
|
||||
The invariants are that second-class borrows cannot become stored members and repetition cannot duplicate a linear value. AIR still independently checks the same rules. No allocation, lifetime, task transfer, cleanup, deterministic interpreter behavior, syntax, code/reason, feature, verifier/runtime state or evaluation input changes. Valid linear lists explicitly unpack/release their owners; Copy and temporary-slice programs run unchanged. Invalid-source errors formerly reaching E1001/E0006/E7900 now stop earlier; the preceding own.array borrow-array fixture now rejects at its literal. New source tests and CLI/package/profile checks cover the changes. Source bundle growth is recorded in docs/agent/README.md; Q-046 records the separate inferred-wrapper audit, and P6-2 remains open.
|
||||
|
||||
Validation: full conformance 1,364/1,364; all 29 new fixtures pass with per-instruction collection. Unit tests pass 128/128. CLI integration passes 152 checks covering exact positions/fields, all diagnostic commands, never-valued calls, generic package provenance, source/AIR/hosted parity and formatter idempotence; the preceding own.array suite remains 119/119. Formatter passes 4,664 checks over 1,078 public files (1,070 parsed, eight existing syntax errors, 642 identical AIR outputs); source coverage remains 121/121. Comparison of 1,049 preceding public sources finds only two expected invalid-program diagnostic changes, with unchanged acceptance and every other canonical lowering identical. No AIR verifier/runtime files change. Independent Claude review passes.
|
||||
@@ -205,7 +205,7 @@ The value is evaluated first, then the place is borrowed for the store and the b
|
||||
|
||||
**Arrays and byte strings.**
|
||||
|
||||
- `[e; N]` evaluates `e` once and copies the value N times (`array.splat`). The element must be copyable; a linear element rejects (E1001 for the §16 surface).
|
||||
- `[e; N]` evaluates `e` once and copies the value N times (`array.splat`). The element must be Copy; a non-Copy value rejects E7005 at `e`, with `constraint: Copy` and `type_constructor: array`. A borrowed element retains E7006 `invalid_literal`.
|
||||
- `b"…"` is an immutable `[u8; N]` value held in frame storage, written there byte by byte, with no heap. The escapes are exactly `\n \r \t \\ \" \0 \xNN`.
|
||||
- Used where a `slice<u8>` is expected, it is borrowed for the operation.
|
||||
|
||||
@@ -404,6 +404,7 @@ A byte string or array used where a `slice<u8>` is expected is materialized in f
|
||||
- slice element types of `slice.copy`;
|
||||
- the element rules of channels and mutexes (no borrow, scope, task, shield or guard).
|
||||
- Copy content of `own_array<T>` and the repeated value of `own.array`; an invalid content type is E7005 at that annotation/value, with `constraint: Copy` and `type_constructor: own_array`. Known linear content in unused generic signatures and static contracts MUST reject; unknown type parameters are checked after substitution.
|
||||
- Inferred array literal elements MUST satisfy the existing member-position rules. Borrowed elements reject E7006 `invalid_literal`; other invalid constructors reject E7005 at the element with `position: member` and `type_constructor`. Lists preserve explicit linear transfers; repetitions MUST satisfy Copy.
|
||||
|
||||
Source type annotations MUST satisfy the existing AIR type-position rules (spec 07 §8.3/§8.8), including nested constructors. An invalid constructor is E7005 at its annotation, with `position` and `type_constructor` fields. Known constructors in unused generic signatures and static function contracts MUST be checked; restrictions depending on a type parameter are checked after substitution. Graph-content properties and feature gates for otherwise correctly positioned types retain their verifier diagnostics.
|
||||
|
||||
|
||||
Reference in new issue
Block a user