fuellabs/sway
🌴 Empowering everyone to build reliable and efficient smart contracts.
How sway is put together
Sway is the Rust-based compiler and toolchain for the Fuel blockchain's Sway smart-contract language, heavily inspired by Rust. The repo is a Cargo workspace of ~20 crates: a lexer/parser (sway-parse), AST (sway-ast), semantic analysis and IR generation (sway-core), an SSA-style intermediate representation with optimization passes (sway-ir), diagnostics (sway-error/feature flags in sway-features), plus shared types/utils. On top sit Forc, a cargo-like package manager/build tool (forc, forc-pkg, forc-test, forc-util, forc-plugins/*) that fetches git/tar dependencies, compiles packages to Fuel VM bytecode (or EVM), runs unit tests on an embedded fuel-vm, and publishes packages; sway-lsp provides a Language Server; swayfmt formats code; sway-lib-std is the standard library written in Sway itself. Data flow: Forc.toml manifest -> dependency resolution/locking -> parse -> typecheck -> IR generation -> optimization -> Fuel/EVM assembly generation -> bytecode deployed or executed against fuel-vm.
Languages
Frameworks
Infrastructure
Major components
sway-parse / sway-ast
Lexing and parsing of Sway source into a typed abstract syntax tree.
sway-core
Compiler core: build configuration, semantic analysis, name resolution, type checking, monomorphization, and lowering to IR (ir_generation.rs).
sway-ir
SSA-style intermediate representation with context/slotmap storage, verification, parser/printer, and an optimization pass manager.
sway-error / sway-features
Structured diagnostics (lex, parse, type errors, warnings, handler infrastructure) and feature-flag gating for experimental language features.
forc + forc-pkg + forc-util
The Forc CLI: project manifests, dependency fetching from git/tarball/registry sources, lockfile management, building, and shared CLI utilities including filesystem locking.
forc-test
Building and executing Sway unit tests inside an embedded Fuel VM, including test setup and gas accounting (ecal.rs).
sway-lsp
Language Server Protocol implementation over tower-lsp providing hover, completion, goto-definition, rename, semantic tokens, inlay hints, and custom extensions like show_ast/visualize.
sway-lib-std + swayfmt + forc-plugins
Standard library written in Sway (storage, crypto, vec, asset ops), the code formatter, and plugin subcommands (doc, fmt, lsp, migrate, publish, tx, debug).
A quiet week with one documentation update aimed at making versioning and release practices clearer and safer.
4 weeksWeek of 2026-08-17
Week of 2026-08-17latest
A quiet week with one documentation update aimed at making versioning and release practices clearer and safer.
Week of 2026-08-10
A busy week of internal restructuring, headlined by splitting the compiler pipeline into distinct AST, IR, and ASM stages.
Week of 2026-07-27
The compiler moved to version 0.72.0 alongside a new memory-comparison intrinsic and optimizer improvements.
Week of 2026-07-20
Optimizer fixes and hashing speedups dominated the week, plus a fix for enum constant evaluation.
Over the past few weeks the Sway compiler team has been focused on a major internal restructuring: splitting compilation into clearer stages (AST to IR to ASM) and making core components like the declaration engine more robust. Alongside that groundwork came steady performance work (smarter inlining, faster hashing, new optimization passes), several correctness fixes for edge cases, and routine dependency updates. The most recent week was quieter, with a single documentation update clarifying versioning and publishing practices.
Week by week
2026-08-17A quiet week with one documentation update aimed at making versioning and release practices clearer and safer.latest1 change
Docs
Clearer versioning and publishing guidance
Documentation now explains version numbering more clearly, gives measured performance guidance, and makes the publishing process fail closed so mistakes are caught rather than silently released.
2026-08-10A busy week of internal restructuring, headlined by splitting the compiler pipeline into distinct AST, IR, and ASM stages.6 changes
Refactor
Compiler split into AST, IR, and ASM stages
The single monolithic compilation step was broken into three clearer phases, making the compiler easier to understand and improve.
Refactor
Smarter function inlining
The heuristic that decides when to inline functions was improved so the final inlined result doesn't grow too large.
Fix
Better error reporting with scoped errors
A new helper ensures errors are reported within their proper scope, fixing cases where error messages were emitted incorrectly.
Refactor
Faster type checking via finalization pass
An optimization to the declaration engine speeds up type checking by deferring work until it's actually needed.
Refactor
Declaration engine cleanup
The component that stores code declarations was reworked for greater robustness and more consistent behavior.
Fix
Fixed copy-propagation cycle detection
A bug in detecting loops during an optimization pass was corrected, preventing potential infinite processing.
2026-07-27The compiler moved to version 0.72.0 alongside a new memory-comparison intrinsic and optimizer improvements.4 changes
Chore
Version bump to 0.72.0
The project's version number was raised to 0.72.0 as part of its regular release cycle.
Feature
New __mem_rep_eq intrinsic
A built-in function for comparing memory representations directly was added, giving developers a faster low-level comparison option.
Fix
All optimization passes registered
Several optimization passes were missing from the central list and are now properly included so they actually run.
Refactor
Standardized entry-block checks
A common way to check whether a code block is the entry point was rolled out across the codebase for consistency.
2026-07-20Optimizer fixes and hashing speedups dominated the week, plus a fix for enum constant evaluation.4 changes
Refactor
Faster hashing via trivial-hash detection
The compiler now recognizes when hashing work is trivially simple and skips unnecessary overhead, speeding things up.
Fix
Fixed SROA optimization across multiple blocks
An optimization that simplifies variable storage was fixed to handle values loaded in different code blocks correctly.
Fix
Corrected runtime representation of enums
Fixed how enum instances are represented at runtime and evaluated as constants, resolving incorrect behavior.
Chore
Dependency update for test tooling
A third-party library used by the test harness was updated to a newer version for security and maintenance reasons.
Dependencies and code review
Dependency advisories
Security Watch
No known advisories across 0 scanned dependencies.
No known advisories in the scanned dependencies.
Code review
No concrete code-level issues confirmed.
Get this report every week for your repos.
GitZoid learns each repo, reports what changed, and flags what needs attention. One flat price for the whole team.
$19 a month, flat · First 10 outputs free · No card required