Skip to main content

Module validate

Module validate 

Source
Expand description

Validation — comprehension_forms.md §5 (V1-V9) and §5.8 (modes).

validate is the single entry point. Walking the AST bottom-up, every variant’s V-axiom checks fire; any failure produces a typed ValidationError. Degenerate-but-defined compositions emit a ValidationWarning in Permissive mode and become hard errors in Strict mode. The compile stage (CompiledComprehension::from_ast and the for lowering) runs it on the tree as written, before any rewrite, so acceptance is a property of the source text, and every rewrite keeps an accepted tree accepted.

V4 (per-strategy input-shape contract) fires at two times (comprehension_forms.md §10.7.8):

  1. Compile time — this module, against the AST’s static metadata-derived IndexFn. For crate::iteration::comprehension::eval_source::EvalClass::Static sources the static IndexFn equals the runtime IndexFn, so a tree accepted here is never refused at a strategy. A ContextRequired source (a Generator that references a name, a WorkloadParamList) is judged by what its text declares: its cardinality_hint, or an unknown count.
  2. Strategy invocation — the runtime evaluator (crate::iteration::comprehension::runtime::evaluate_indexed) calls crate::iteration::comprehension::strategies::Strategy::accepts_input against the evaluated input’s index_fn. For a context-required source this is the authoritative check.

Structs§

NameRead
A name a comprehension reads where it does not bind it (outer_reads).
ValidationReport
Result of a validation pass.

Enums§

Mode
Validation mode (comprehension_forms.md §5.8).
ReadSite
Where a comprehension reads a name (comprehension_forms.md §5 V3).
Surface
What a consumption surface supplies to the names a comprehension’s sources and predicates read (comprehension_forms.md §5 V3, §9.5).
ValidationError
V-axiom violation. Each variant carries enough context to produce a useful diagnostic at the call site.
ValidationWarning
Non-blocking warning for degenerate-but-defined compositions (comprehension_forms.md §5.8).

Functions§

check_names
V3 under strictness (comprehension_forms.md §5): every name a clause source or a filter predicate of c reads is bound by the comprehension where it is read, or supplied by surface. The error names each name that is neither, with where it is read (unresolved_names).
outer_reads
Every name c reads where it does not bind it, in tree order, once per place it is read (comprehension_forms.md §5 V3).
unresolved_names
Every name a clause source or a filter predicate of c reads that neither the comprehension binds where it is read nor surface supplies, with where it is read, in tree order (comprehension_forms.md §5 V3). Under pragma strict each is an error (check_names); outside it each is a warning, and the name reads None.
validate
Validate a comprehension AST as written (comprehension_forms.md §5).