Skip to main content

resolve

Function resolve 

Source
pub fn resolve(package: &Package) -> Result<Program, Vec<Diagnostic>>
Expand description

Resolves every module of package into the flat program the runtime executes.

Because a module may name another module’s exported declarations, this is a package-wide pass rather than a per-module one:

  1. each module’s surface — what it declares, and whether each declaration is exported — is collected, since a use in one module is answered by another module’s declarations;
  2. every use is resolved against the package’s modules first and the host registry second (ADR 0005);
  3. the module dependency graph is checked for cycles, which ADR 0005 forbids;
  4. each module’s own declarations are merged across its units;
  5. required capabilities, and the reasons they are only a lower bound, are derived as a fixed point over the package’s call graph, so a function reaching a Host API through an imported helper reports it and a function reaching an indirect call through one says so;
  6. every body is checked against everything now known, including enums reached through an import.