lang::typecheck::view_rules
lang/src/typecheck/view_rules.mo
The view-types soundness rules (plans/type-system/view-types.md,
Phase 1).
These are ERRORS on every path, regardless of a mote's [affine] mode
(lang/mote.toml is warn): a safety rule that a warn mote could
downgrade is not a rule. module.mo's
check_module_with_scope_classified appends them to errors in both
modes.
The rules, in the order they appear below:
- Forced linearity lives in
affine.mo'seffective_mult_with_kinds: a#[proof]type is linear, a#[linear]type is linear unless?xrelaxes it to affine.?/%on a proof is rejected there (proof_erased_binder). - No Copy/Clone: a declared instance for one is rejected
(
check_instance_kinds). The affine rule consultsis_linear_type/is_proof_typeBEFOREis_copy, so no implicit ω-route reaches a linear type; an explicitCopy.copywould need the instance this rule rejects. - No capture (P10): a linear or proof value used under a nested lambda. The closure body counts it once but may run many times, and eager fibers run closures on other threads.
- No re-readable container (P11): a linear/proof value passed to
Shared.of(counted asBinderUse.borrowed), or a signature/field typedShared/Ref/Arrayover one. - Proofs are phantom in v1: a user def may not bind or return a proof type, because nothing erases it yet.
Deliberately NOT a rule in v1: passing a linear value to an arbitrary
polymorphic function whose parameter type is a bare type variable. That
needs the callee's instantiated signature at the call site (the same
interprocedural information gap as Shared.get's owning-argument case,
QTT Known Gap 12) and is documented as a residual.
pub def check_module_view_errors (scope : Scope) (decl_list : List Decl) : List TypeErrorEvery view/proof diagnostic a module earns. Built once per module: the kind sets and the two name sets are scope scans, not per-binder lookups.
pub def check_module_view_diags (path : Option String) (scope : Scope) (decl_list : List Decl) : List StringThe same errors, rendered with the owning declaration's name as the
diagnostic context. Always error: — a warn mote must not downgrade a
safety rule.