Skip to main content

check_module_with_environment

Function check_module_with_environment 

Source
pub fn check_module_with_environment(
    module: &ModulePath,
    modules: &ModuleSet,
    environment: &AdamCheckingEnvironment,
    availability: MetadataAvailability,
) -> ModuleCheckingReport
Expand description

Checks every registered definition and composed root with a data-only environment.

Definitions use the resolver’s dependency postorder and ordinary source-mask policy. Every branch contributes structure, including inactive/default branches. Match-key value comparisons and whole-graph solvability remain runtime checks. Labels retain genuine source and invocation ownership independently of modules.

Equivalent component uses share structural facts. Diagnostics retain deduplicated authored labels and a deterministic representative invocation chain, not one copy per expanded occurrence or an expanded graph’s shortest explanation.

  • Complexity: Expression checking plus expected O(B(V + E) + B² + N + A) time per distinct reachable definition/formal-source specialization, where B counts formals plus one write entry, V and E count compact local vertices and edges (including direct child summaries), N body nodes and authored method/guard endpoints, and A direct argument endpoints. Retains O(BV + B² + E + N + A) storage per specialization plus diagnostic output. Materializing each diagnostic visits its shared witnesses once. Distinct source masks can be exponentially numerous; repeated equivalent uses do not expand occurrences. Construction and witness traversal are iterative.

§Examples

use adam_lang::*;
use cel_parser::checking::MetadataAvailability;
let mut modules = ModuleSet::new();
let path = "app".parse().unwrap();
modules.insert_source(path, "app.adm2", "sheet app { cell x: i32; }").unwrap();
let environment = checking_environment(&TypeRegistry::new(), &cel_parser::OpLookup::new()).unwrap();
let report = check_module_with_environment(&"app".parse().unwrap(), &modules,
    &environment, MetadataAvailability::Complete);
assert!(report.diagnostics.is_empty() && report.incomplete.is_empty());