pub enum ModuleStatus {
Unlinked,
Linking,
Linked,
Evaluating,
EvaluatingAsync,
Evaluated,
}Expand description
Where a module is in its lifetime.
Linking and Evaluated are not just bookkeeping: they are what makes a cycle
terminate. A cycle is not an error — it is a graph that must be linked depth-first
and then evaluated in post-order, and the two-phase split is the mechanism.
Variants§
Unlinked
Loaded and compiled; imports not yet resolved.
Linking
Being linked, so a re-entrant link must not recurse.
Linked
Imports resolved and exports validated.
Evaluating
Body running right now.
Distinct from ModuleStatus::Evaluated because the deferred-import proposal asks
the difference: ReadyForSyncExecution answers false for a module that is
~evaluating~, and the only way a namespace read can observe that is if the two
states are not the same flag. A re-entrant evaluation still stops at either.
EvaluatingAsync
Body suspended at a top-level await, or waiting for a dependency that is.
§16.2.1.5.3.1’s ~evaluating-async~. A module in this state has a body that has
started — its [[AsyncEvaluation]] is set and it holds an
[[AsyncEvaluationOrder]] — and it will be moved to Evaluated by the module
machinery, not by whatever call happened to reach it.
Evaluated
Body has run to completion, or has failed.
A body that threw is Evaluated too — §16.2.1.5.3.1 records the completion in
[[EvaluationError]] and marks the module evaluated, so a second attempt reports
the same exception object rather than running the body again.