diag: explain pointer-sized cast restrictions in source advice
This commit is contained in:
1 parent
8a714ba6de
commit
6a02659f31
23 files changed
+96
-8
No files matched your search
@@ -176,3 +176,5 @@ Q-052 CFG resource provenance (DD-024): Quick Reference and other/full source do
|
||||
P6-7 factual source E4202 fields (cl100k): Quick Reference stays 8,955; other source docs 68,323 → 68,353 (+30), full source 77,278 → 77,308 (+0.04%). o200k groups are 8,991 / 68,556 / 77,547; Qwen2.5 9,233 / 70,024 / 79,257. Only language/concurrency.md grows; AIR and library/std.md are unchanged. Concrete `found` and `use` fields distinguish ordinary atomic reads without message parsing. No new syntax, code, feature or verifier/runtime state is introduced; no empirical MCC benefit is claimed.
|
||||
|
||||
Spec 15 scope corrections (cl100k): Quick Reference stays 8,955 tokens despite the E1002 → E7005 correction; other source docs 68,353 → 68,403 (+50), full source 77,308 → 77,358 (+0.06%). o200k full source grows 77,547 → 77,594 (+47); Qwen2.5 79,257 → 79,315 (+58). AIR and std are unchanged. Existing source diagnostics, unpacking, escapes, buffers and borrow returns replace obsolete baseline descriptions; no semantic or implementation change.
|
||||
|
||||
Pointer-sized cast guidance (2026-10-09): Quick Reference grows 9,255 → 9,276 cl100k (+21); other source docs 69,817 → 69,863 (+46), full source 79,072 → 79,139 (+67, +0.085%). o200k grows by the same +21/+46/+67 (full 79,373); Qwen2.5 by +21/+47/+68 (full 81,127). AIR grows 188,993 → 189,078 bytes and +22 tokens for each tokenizer (48,398 cl100k / 48,551 o200k / 49,956 Qwen2.5). The existing target-independent ban on usize/isize widening is explained in the registered numeric-cast hint and source cast table. No new concept, syntax, feature, diagnostic code/kind or verifier/runtime state is introduced. Pointer identity casts now reject with source E7005/advice before AIR E1002; the accepted set is unchanged. No empirical reduction in repair rounds is claimed.
|
||||
@@ -86,7 +86,7 @@ return x + y + w; // also: `trap;`
|
||||
| `+% -% *%` | wrapping |
|
||||
| `& \| ^ << >>` | bitwise; shift ≥ width traps `T0005` |
|
||||
| `== != < <= > >=`, `and or not` | comparisons, booleans |
|
||||
| `x as T` | lossless widening only (else `E7005`) |
|
||||
| `x as T` | lossless fixed-width widening only; `usize`/`isize` use `as!` or `as%` (else `E7005`) |
|
||||
| `x as! T` | checked conversion, traps `T0006` |
|
||||
| `x as% T` | wrapping conversion |
|
||||
| `42`, `42u8`, `0xff`, `1_000` | literals; type from context or suffix (else `E7007`) |
|
||||
|
||||
@@ -388,3 +388,9 @@ The [AIR binding candidate](../design/contract-air-bindings.md) supplies prefix/
|
||||
The [runtime/context candidate](../design/contract-runtime-and-context.md) specifies frame continuations, normal completion only after validation, free normalization before quantum checks, depth/fuel precedence, traced pending roots and exact additive failure context. Six ordinary groups pass 16 CLI runs at quantum 1; nine fixture variants pass GC-every-step record comparison (13 schedule cases, 26 interpreter runs). Six hypothetical schema components are explicitly unimplemented. Claude independently reproduced the CLI records and reviewed the rules; corrections fixed old/make/modify modes, race context and AIR-only byte-identity exploration. No normative/compiler/registry/bundle changes are made. Source reasons, compatibility/model adoption, RFC 0040 observations and full vertical runtime tests remain gates; RFC 0039 stays Draft and full P6-6 remains doing.
|
||||
|
||||
The [source rejection/compatibility audit](../design/contract-source-errors-and-compatibility.md) proposes eight new E7006 reasons and retains existing source type/name/transfer codes, error collection and mapped verifier obligations. Ten executed current-language AIR0 probes preserve full diagnostics and distinguish dependent undefined results from independent SSA errors; neither the historical parser nor contract semantics is executed. Owner selection of the module-state model, Q-055 compatibility/version policy and RFC representations remains necessary before normative integration and vertical implementation. No fresh Claude review was available for this increment. RFC 0039 remains Draft; P6-6 remains doing.
|
||||
|
||||
## P6-12 pointer-sized cast guidance (2026-10-09)
|
||||
|
||||
Public development feedback identifies u8 → usize and usize → u64 casts rejected without explaining the target-independent rule. Spec 02 §2 already excludes usize/isize from widen, including conversions that fit under every current target. The registered numeric_cast_modes hint now states that rule, keeping the original E7005 message/fields and checked/wrapping alternatives. Source/Quick Reference cast tables explain it too; no semantic widening extension is adopted. Pointer identity as casts now follow the same source rejection instead of leaking AIR E1002 without advice. Six rejection fixtures and an explicit checked/wrapping runtime case cover the rule; hosted advice tests pass 208 checks including source API parity and fixed-width identities. Bundle growth is measured in agent/README.md. Parameter-mutability and array-to-slice advice from the same feedback remain open work; no new dev/model experiment or repair-round benefit is claimed.
|
||||
|
||||
Validation of cast guidance: units/format checks and all 1,776 conformance cases pass. Comparison of 1,403 pre-existing source files changes only the registered hint; all 500 accepted lowerings remain byte-identical.
|
||||
@@ -126,7 +126,7 @@ These stable kinds use spec 10 §3. `hint` MUST equal the registered text. Alter
|
||||
| `borrow_argument` | E7001 | Write `ref place` or `mut place` for an inline borrow argument. | prefix |
|
||||
| `borrow_binding` | E7001 | Bind a borrow with `ref name = place;` or `mut name = place;`, rather than a let/var initializer. | none |
|
||||
| `zero_storage` | E7001 | `zero` is only a whole var initializer: `var name: T = zero;`; T must be zeroable. | none |
|
||||
| `numeric_cast_modes` | E7005 | Choose `as!` for a checked conversion (T0006 on overflow) or `as%` for a wrapping conversion. | operator |
|
||||
| `numeric_cast_modes` | E7005 | The target-independent `as` rule excludes `usize`/`isize`, even when the value fits. Choose `as!` for a checked conversion (T0006 on overflow) or `as%` for a wrapping conversion. | operator |
|
||||
|
||||
Closed applicability:
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ Lowering: structured control flow becomes blocks and terminators. A variable ass
|
||||
|
||||
| Source | AIR |
|
||||
|---|---|
|
||||
| `x as T` | `cast.widen`; only where every value is representable, otherwise source `E7005` (§10; AIR `E1002`) |
|
||||
| `x as T` | `cast.widen`; lossless fixed-width integers only; `usize`/`isize` require `as!` or `as%` (spec 02 §2); otherwise source `E7005` (§10; AIR `E1002`) |
|
||||
| `x as! T` | `cast.checked` (`T0006`) |
|
||||
| `x as% T` | `cast.wrap` |
|
||||
|
||||
|
||||
Reference in new issue
Block a user