Skip to main content

Internals

These pages are for people working on Bolt itself. Each page answers one question, and that decides where it is:

  • Compiler: how a stage of the compiler works.
  • Designs: why a feature of the language is the way it is, with what was considered instead and what's still to decide.
  • Tooling: how packages are found and the compiler is run.
  • Proofs: the Lean proof of the mutability rules, what it covers, and how it links to Bolt.

A design that isn't fully built yet says so in a box at its top, so pages don't move when they're implemented.

The compiler​

A program goes through these stages, each a crate in crates/:

StageCratePages
Lexing and parsing into a lossless treeboltlang-parser, boltlang-syntaxSyntax
Definitions, name resolution and bodiesboltlang-hir-defDefinitions and names
Type checkingboltlang-hir-tyType checking
Building MIR, with patterns as decision graphsboltlang-mir-build, boltlang-patternMIR
Passes over MIR, like desugarings and shimsboltlang-mir-transformMIR
Monomorphizationboltlang-mir-monoMIR
Lowering to Conduitboltlang-codegen-conduitConduit

Conduit, the IR that Bolt compiles to, is a project of its own. It runs programs in an evaluator and compiles them to WebAssembly.

Around the stages:

  • boltlang-base-db is the base of the Salsa database, with files and their syntax trees. Every stage is made of queries on it, so the language server only redoes what an edit affects.
  • boltlang-hir is the semantic model of a program for tools, and boltlang-ide-diagnostics turns what the stages report into diagnostics with a code, a severity and a message.
  • bolt-language-server and bolt-language-server-wasm are the language server, natively and in the browser. boltlang-cli is the bolt command.
  • boltlang-std holds the std package (see Packages), and boltlang-corpus the format of the test files in tests/.

Designs​

DesignStatus
Mutabilityimplemented
Parameter namesimplemented
Effectschecked and run; some of it is still to decide
Asyncpartly: tasks and an executor in std
Reactive UIa proposal