Skip to main content

check_module_recovering

Function check_module_recovering 

Source
pub fn check_module_recovering(
    package: &PackageName,
    interfaces: &HashMap<Name, Interface>,
    source: &Module,
) -> Outcome<CheckedModule, CompilationError>
Expand description

Apply every check to one parsed module, and hand back the module the checks built beside everything they found wrong with it.

The module always comes back, as Outcome::Module: an import that does not resolve is an error beside it and not a reason for there to be none. It holds every declaration that canonicalized, whatever canonicalization, the typer and the exhaustiveness check say, with a CompilationError::Canonical, a CompilationError::Type and a CompilationError::Exhaustiveness for whichever of them reported anything. An empty error list does not say that the module checked whole: a not-found error raised in an incomplete scope is dropped, so a module can come back with no error and with declarations in canonical::Module::broken or holding a hole; the driver reads the flag beside the list.

Its IR holds a typed declaration for every value the typer did not reject, and lists each rejected one, and each declaration canonicalization recorded in canonical::Module::broken, in ir::Module::unchecked with reported set, which no backend emits. A name that did not resolve stands in a typed declaration as a hole, which no backend emits either.

TODO canonicalization must happens before checkings, because type check (at least) will require access to other modules canonical representation. That probably mean moving the canonical::canonicalize call out of this function

Whether source’s package is exempt from the default imports is not decided here: canonical::canonicalize_recovering derives it from package itself (PackageName::is_core), so this function needs nothing beyond the package it already receives — which is why check in ModuleWalker::check_in_order can carry this as a plain fn pointer over the package alone.