cli: reject non-value operands without aborting lowering

This commit is contained in:
dev committed 2026-10-08 12:17:15 +03:00
1 parent bc5412dadd
commit dcd5f1f702
83 files changed
+1042 -38

No files matched your search

+8
View File
@@ -346,3 +346,11 @@ Audit each constructor against its own existing content/position/property rules
Q-046 review identified other uses of `never` that reach lowering with no current block. Independently reproduced: `module test.never_operand fn stop() -> never effects [] { trap; } fn main() -> u64 effects [] { return 1u64 + stop(); }` aborts while `Lowerer.binary` calls `def`/`emit` after `stop()` terminated the block. Review also reproduced ordinary call arguments and struct fields; their exact scope remains unverified. Q-046 guards constructor content only.
Audit non-value operands in ordinary calls, operators and aggregates against spec 15 before emission. Distinguish value-requiring positions from valid void statements and never-returning control flow. Add source rejection/acceptance and CLI tests, preserving evaluation order, explicit transfers, diagnostics and canonical AIR for valid source. A source program MUST NOT cause a lowering panic; do not infer a new divergence/coercion rule from implementation behavior.
**Resolved (spec 15 §10):** typed operation inputs reject never with E7005 at the operand (`expected`, `found: never`) before subsequent inputs/emission, while ordinary void mismatches retain their diagnostics. Calls, operators, fields/payloads, conditions, ranges/indices, sizes, atomics, channels and place-store values use this rule. `select` checks a divergent send value before endpoint borrows. Return/tail/statement/branch divergence and existing SSA variable receivers remain valid; divergent assignment by name or `var` initialization in frame storage now performs no store. Binding/annotation checks still precede those receivers. Place writes through `*`, fields or indices require a value; rejecting never before target evaluation prevents formerly invalid targets from being accepted. Unknown target types use `expected: a stored value`, so earlier E7002 can become E7005 at the RHS. `let` retains its existing no-value error. Emission into a terminated block returns E7006 unreachable rather than aborting; a state-machine unit test preserves the terminated block and diagnostic span. AIR acceptance, ownership/lifetime rules, effect/capability contracts, normal-path execution and accepted-source canonical AIR are unchanged. Programs that previously aborted now reject or, for valid variable receivers, diverge normally. Q-048 records a separate store-mode gap.
## Q-048 — Source place-store access modes
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.