cli: validate exclusive source places before AIR
This commit is contained in:
1 parent
dcd5f1f702
commit
41f3afbf05
54 files changed
+541
-2
No files matched your search
@@ -164,3 +164,5 @@ Q-045 inferred array literals (cl100k): Quick Reference stays 8,948; other sourc
|
||||
Q-046 inferred constructor content (cl100k): Quick Reference stays 8,948; other source docs 66,906 → 67,074 (+168), full source 75,854 → 76,022 (+0.22%). o200k groups are 8,984 / 67,279 / 76,263; Qwen2.5 9,226 / 68,724 / 77,950. AIR remains 184,628 bytes / 47,445 cl100k tokens; library/std.md is unchanged. Existing value/Copy/borrow restrictions now reject at constructor arguments, including generic templates, before malformed AIR or null-block failure. Complete linear packing and recovery remain valid; graph/endpoint feature diagnostics keep their existing precedence. No new concept, syntax, code/reason, feature or verifier/runtime state is added. Accepted canonical AIR is preserved; invalid-source diagnostics may change. No empirical MCC benefit is claimed.
|
||||
|
||||
Q-047 non-value operands (cl100k): Quick Reference stays 8,948; other source docs 67,074 → 67,258 (+184), full source 76,022 → 76,206 (+0.24%). o200k groups are 8,984 / 67,461 / 76,445; Qwen2.5 9,226 / 68,912 / 78,138. AIR remains 184,628 bytes / 47,445 cl100k tokens; library/std.md is unchanged. Typed operation inputs reject never before subsequent emission; divergent returns/branches/statements and variable receivers retain their control flow, and frame receivers skip writes. Store values remain required. Invalid-source diagnostic order may change; accepted canonical AIR is preserved. No new concept, syntax, code/reason, feature or verifier/runtime state is added. No empirical MCC benefit is claimed.
|
||||
|
||||
Q-048 source access modes (cl100k): Quick Reference stays 8,948; other source docs 67,258 → 67,343 (+85), full source 76,206 → 76,291 (+0.11%). o200k groups are 8,984 / 67,546 / 76,530; Qwen2.5 9,226 / 69,001 / 78,227. AIR remains 184,628 bytes / 47,445 cl100k tokens; library/std.md is unchanged. Shared places reject at source stores and explicit mut bindings/arguments before array shape conversion; valid canonical AIR is preserved. No new concept, syntax, code/reason, feature or verifier/runtime state is added. No empirical MCC benefit is claimed.
|
||||
@@ -354,3 +354,9 @@ Audit non-value operands in ordinary calls, operators and aggregates against spe
|
||||
Q-047 review independently reproduced `fn update(p: ref<u64>) -> void effects [] { *p = 1u64; }`: it reaches AIR E1001 (`expected: mut<T>`, `found: ref<u64>`) instead of frontend E7xxx, although the mode is determined by source types (spec 15 §10). Review also observed accepted writes to fields of a `let` aggregate. An immutable binding does not necessarily imply immutable owned content; whether that behavior disagrees with the specification remains unverified and MUST NOT be guessed from the binding's `mutable` flag.
|
||||
|
||||
Audit existing place modes and referents against spec 15 §4/§5 and AIR borrow/store rules. Reject fully type-decided incompatibilities at the source, preserving ownership, aliasing/lifetime diagnostics, evaluation order and canonical AIR for valid source. Determine the binding/content distinction from governing text before proposing any semantic restriction.
|
||||
|
||||
**Resolved (spec 15 §10):** stores require `mut<T>`; explicit `mut` bindings and arguments require an exclusive place before array-to-slice conversion. Shared places reject E7005 with expected/found borrow types at the place or argument. This also prevents accepted `mut` bindings from silently retaining shared field/index/range modes, or requesting an exclusive slice from a shared array. Dereferenced slices are not scalar store places. Whole-array stores retain E7006; RHS evaluation, valid canonical AIR, ownership/projection/alias/lifetime rules and runtime semantics remain unchanged. Q-049 separates the unresolved Copy-let storage policy.
|
||||
|
||||
## Q-049 — Immutable Copy bindings and mutable frame content
|
||||
|
||||
Read-only Q-048 review reproduced accepted `let p = Pair { a: 0u64 }; p.a = 42u64; return p.a;`, and exclusive borrows of Copy-let frame storage. Spec 15 §4 calls `let` an immutable binding; assignment by name already rejects. Whether this should also prohibit content writes through fields/indices/borrows is unresolved. Owned content through `let` intentionally remains mutable and is used by public std examples. Do not infer a new restriction from `Binding.mutable`: distinguish Copy frame storage from owners, regions, resources and borrow bindings, and settle the normative policy before changing accepted source. This question is independent of Q-048's existing shared/exclusive borrow modes.
|
||||
@@ -277,3 +277,11 @@ Q-047/spec 15 §10 distinguishes typed operation inputs from divergent control f
|
||||
The preserved invariants are that no missing value becomes an operand or store and no write/borrow is emitted after control flow terminates. AIR independently retains its type, ownership, lifetime and effect/capability rules. Runtime cleanup, abnormal-path resource handling, deterministic execution and accepted-source canonical AIR are unchanged. Positive cases cover variable receivers in SSA/frame storage, normal/trapping branch paths, ownership and returned views; rejected cases cover non-value inputs and malformed place targets. Former compiler aborts now produce a diagnostic or valid variable-receiver divergence. Invalid diagnostic order may change, including place RHS errors before unknown targets. No new syntax, diagnostic code/reason, feature, verifier/runtime state or evaluation input changes. Source bundle growth is recorded in docs/agent/README.md. P6-2 remains open; Q-048 is the separately reproduced store-mode gap, and Q-044 remains an implementation-cost audit.
|
||||
|
||||
Validation: full conformance passes 1,497/1,497; unit tests and Zig formatting pass. The 75 new fixtures pass with collection before every instruction and the CLI suite passes 635 checks, including exact positions/fields across diagnostic commands, source/AIR/hosted trap/return parity, formatting and imported generic reachability. Existing constructor/literal/owning-array/linear CLI suites pass 302/152/119/49 checks. Final comparison on 1,136 preceding public sources (659 successful old lowerings) has zero changed check or canonical lower outputs. The formatter corpus passes 5,098 checks on the first 1,200 public files (1,192 parsed, eight existing syntax errors, 676 identical AIR outputs); CLI formatting covers all 75 new fixtures, including the eleven later additions. Source coverage remains 121/121.
|
||||
|
||||
## P6-2 source place access modes (2026-10-08)
|
||||
|
||||
Q-048/spec 15 §10 rejects stores through shared borrows, and checks explicit `mut` bindings/arguments before whole-array-to-slice conversion. Scalar stores require exactly `mut<T>`; dereferenced slices reject. E7005 carries expected/found borrow types at the place (binding/store) or argument. Existing whole-array E7006 and RHS evaluation order remain. Valid exclusive stores, shared reborrows, projections, array/slice views and owned content use unchanged AIR. Previously accepted `mut` bindings through shared fields/indices/ranges now reject; invalid argument diagnostic details can change.
|
||||
|
||||
The preserved invariant is that explicit `mut` cannot create exclusive access from shared access. AIR independently enforces borrow/store modes, aliases, lifetimes and linear content/projection restrictions. No runtime state, allocation, cleanup, deterministic interpreter behavior, syntax, code/reason, feature or evaluation input changes. Positive source/AIR runs exercise scalar/field/index/range writes and owning content; rejected cases cover shared modes and retained verifier rules. Q-049 records the separate unresolved Copy-let frame-content policy. Bundle growth is recorded in docs/agent/README.md; P6-2 remains open.
|
||||
|
||||
Validation: full conformance passes 1,543/1,543; units and Zig formatting pass. The 46 new fixtures pass with collection before every instruction; CLI integration passes 348 checks, including exact fields/positions, diagnostic commands, formatting, imported generic templates and source/AIR/hosted execution. Existing array-argument/non-value/linear/borrow-return CLI suites pass 85/635/49/133 checks. Comparison on 1,211 preceding public sources (673 successful old lowerings) changes only the message of two rejected inputs; accepted AIR is byte-identical. All eleven new runtime fixtures also retain the previous compiler's AIR. The formatter corpus passes 5,289 checks on 1,257 public files (1,249 parsed, eight existing syntax errors, 686 identical AIR outputs); coverage remains 121/121. Independent read-only review by Claude approved the access-mode checks and confirmed the two diagnostic-message changes.
|
||||
@@ -400,6 +400,7 @@ A byte string or array used where a `slice<u8>` is expected is materialized in f
|
||||
- arity and argument types of functions and built-in operations;
|
||||
- the existence of fields and variants;
|
||||
- `ref`/`mut` compatibility;
|
||||
- A place store MUST require `mut<T>`; a `mut` binding or argument MUST require an exclusive place before whole-array-to-slice conversion. A shared place rejects E7005 at the place (binding/store) or argument with `expected`/`found` borrow types. The RHS is still evaluated first; whole-array stores retain E7006. Content linearity and alias/lifetime checks remain verifier rules.
|
||||
- lossless widening by `as` (the verifier's own rule);
|
||||
- slice element types of `slice.copy`;
|
||||
- the element rules of channels and mutexes (no borrow, scope, task, shield or guard).
|
||||
|
||||
Reference in new issue
Block a user