Check
Units and typelibs to check together, and the modules they need.
A driver adds the units it starts from, then a unit or typelib for each module
missing names that it can find, until every module
still missing is one it has looked for. Then it runs the check, which reports
imports of the modules still missing as not found.
Example
let check = Check()
check.add $(compile "main.dol" $source typecheck: true)
let tried = Set []
let more = true
while more
more = false
for name = check.missing()
if tried.contains(name)
continue
tried.add $name
more = true
let path = Path "lib/$name.dol"
if path.exists()
check.add $(compile "$path" $path.read_str() module: $name typecheck: true)
for diag = check.run().diagnostics
echo $diag.render()
Constructor
Check …
Starts a check of no units.
Parameters
| Name | Type | Description |
|---|---|---|
:typelibs? |
Bool |
Whether the result keeps what Checked.typelib
writes. False by default. |
Methods
add input
Adds a unit, or a module by its typelib.
A unit that failed to compile needs no modules, and the check skips it; its own diagnostics report why.
Parameters
| Name | Type | Description |
|---|---|---|
input |
(Unit | Typelib) |
Errors
| Exception | Condition |
|---|---|
std.ValueError |
input was compiled without typecheck: true, or its module was already added |
std.StateError |
input was emitted |
missing() -> Iterable[Str]
Returns the modules the units added need that none of them is, sorted: those
they import, by statement or through the prelude bindings they use, and
std, which holds the types of literals. Once strand is added, they
include proc, whose pipes check describes.
run() -> Checked
Checks the units added together.
Errors
std.StateError if a unit was emitted after it was added.