Skip to content

check Command Design Document ​

yx check is the static checking entry point of the YaoXiang compiler. It is not a lightweight path that only performs parsing and type checking: a single check runs the complete frontend and middle-end stage table, but does not produce executable artifacts.

Entry Point ​

LayerLocationKey Symbol
Orchestrationsrc/frontend/module/orchestrator.rscheck_project(entry, config)
Driversrc/driver/program.rsProgramKind::Check → CHECK_STAGES
Driver Armsrc/driver/arms.rsThe Check form of each stage

check_project constructs Program { kind: Check } and runs the Driver once. It returns Vec<(file, diagnostics)>; discovered files have an entry even when they have no diagnostics. Vendor, discovery, and parsing failures still hard-abort with OrchestratorError (the existing behavior in 4.10.1).

Actual Stage Table ​

CHECK_STAGES (src/driver/program.rs) contains 12 stages:

  1. VendorConsistency — vendor lock and workspace consistency
  2. Discovery — rebuild the unit set along the use graph
  3. Parsing — lex + parse
  4. Registry — module registration
  5. RoleClassification — project role classification
  6. Typecheck — type checking for each unit
  7. DeadCodeAnalysis — dead code analysis (project scope)
  8. ProofExecution — compile-time proof execution (RFC-027)
  9. GlobalSlotAlloc — global slot allocation
  10. IrGeneration — AST → ModuleIR (in memory only)
  11. Linking — merging only
  12. Monomorphization — monomorphization (the Check form consumes the IR)

Artifact boundary: After IrGeneration, the IR is not emitted, written to disk, used to produce .42, or used to generate a snapshot (DriverOutcome.module is always None); a successful check is silent.

Boundaries with Other Commands ​

CommandWhat It DoesDifference from check
yx checkThe 12 stages aboveDoes not produce executable artifacts; the IR only serves diagnostics and subsequent checking stages
yx build / yx runThe same stage table + code generation + backendProduces .42 and executes it
yx lspProgramKind::Lsp: a single compilation produces diagnostics and semantic dataEditor-oriented; diagnostics are filtered to the target file
yx formatPerforms only lexing and formattingShares no stages with check

Nonexistent Capabilities ​

The following capabilities are not implemented, so do not assume they exist based on older documentation:

  • The --watch flag: The Check subcommand only has arguments such as paths / --exclude; there is no watch mode.
  • Incremental checking: CheckSession / ModuleDependencyGraph / ModuleCache / HotReloader have zero matches in the repository; every check is a full pass.
  • Cross-file analysis with an independent Compiler for each file: check_single_module does not exist. Cross-file capabilities come from the registry and shared environment in src/frontend/module/.

Diagnostics and Error Codes ​

For the error code system, the Diagnostic data structure, and Emitter output, see Diagnostic System.