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):
- Compile time — this module, against the AST’s static
metadata-derived
IndexFn. Forcrate::iteration::comprehension::eval_source::EvalClass::Staticsources the static IndexFn equals the runtime IndexFn, so a tree accepted here is never refused at a strategy. AContextRequiredsource (a Generator that references a name, a WorkloadParamList) is judged by what its text declares: itscardinality_hint, or an unknown count. - Strategy invocation — the runtime evaluator
(
crate::iteration::comprehension::runtime::evaluate_indexed) callscrate::iteration::comprehension::strategies::Strategy::accepts_inputagainst the evaluated input’sindex_fn. For a context-required source this is the authoritative check.
Structs§
- Name
Read - A name a comprehension reads where it does not bind it
(
outer_reads). - Validation
Report - Result of a validation pass.
Enums§
- Mode
- Validation mode (comprehension_forms.md §5.8).
- Read
Site - 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).
- Validation
Error - V-axiom violation. Each variant carries enough context to produce a useful diagnostic at the call site.
- Validation
Warning - 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
creads is bound by the comprehension where it is read, or supplied bysurface. The error names each name that is neither, with where it is read (unresolved_names). - outer_
reads - Every name
creads 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
creads that neither the comprehension binds where it is read norsurfacesupplies, with where it is read, in tree order (comprehension_forms.md §5 V3). Underpragma stricteach 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).