FuelLabs/sway
57.0
Adequate · 11 October 2026
198.4k
lines of production code
Rust
primary language
3
measurements over time
What this system is
This system is the Sway compiler toolchain, providing the infrastructure to parse, type-check, and compile smart contracts into bytecode for the Fuel and EVM virtual machines. It includes a comprehensive CLI interface for project management, dependency resolution, and testing, alongside developer tools for code formatting, documentation generation, and interactive debugging. The core compiler features a modular architecture with SSA-based intermediate representation, advanced optimization passes, and robust semantic analysis to ensure type safety and code correctness.
How it got here
2021–2022 — Initial scaffolding and compiler architecture
78 changes.
This period established the foundational structure of the Sway project, introducing the forc CLI tool, modular compiler engines, and a new SSA-style intermediate representation. It focused on building core developer tooling, including syntax highlighting, code formatting, and a language server, while refactoring the semantic analysis and type systems for improved performance and maintainability.
2023 — EVM backend and LSP expansion
52 changes.
The project introduced an initial EVM backend for bytecode generation and restructured the Fuel assembly pipeline into a modular architecture. Significant effort was directed toward expanding the Language Server Protocol with extensive tokenization tests and adding a new CLI plugin for transaction construction. The period also saw the introduction of a query engine for caching, SSH support for Git dependencies, and a comprehensive refactor of the documentation generator.
2024–2026 — Developer tooling and migration infrastructure
35 changes.
This period focused on expanding the developer experience through comprehensive tooling, including a new DAP-based debugger, an interactive CLI, and a registry publishing system. Significant effort was dedicated to automating code evolution with the forc-migrate tool and centralized feature management, while also introducing robust assembly optimizations and DWARF debug symbol generation.
Features
Add Liquidity Pool example contract
Introduces a new example contract at examples/liquidity\_pool/src/main.sw that demonstrates a basic liquidity pool mechanism. The contract allows users to deposit a base asset to mint corresponding LP tokens (at a 2:1 ratio) and withdraw the base asset by burning LP tokens (at a 1:2 ratio), utilizing standard library functions for asset handling and message context.
_examples/counter, examples/liquidity\_pool, examples/upgradeable\_proxy/implementation, examples/upgradeable\proxy/proxy · high confidence
Add Option example demonstrating safe division
The examples/option directory now includes a script demonstrating the use of the Option type for handling potential failures, specifically showing how to perform safe division by returning None when the denominator is zero and logging the result or an error message via pattern matching.
examples/option · high confidence
Add Result type example for error handling
The examples/result directory now includes a script demonstrating the use of the Result type for handling errors. The example defines a custom error enum and a division function that returns a Result, showing how to handle success (Ok) and failure (Err) cases within a main script.
examples/result · high confidence
Add SSH authentication support for Git package sources
The \forc-pkg\ Git source resolver now supports SSH authentication when fetching remote packages. A new \AuthHandler\ in \forc-pkg/src/source/git/auth.rs\ manages credential callbacks, prioritizing SSH keys via the SSH agent and falling back to user/pass or default credentials. This allows users to access private Git repositories using SSH keys without needing to configure separate credential helpers or use HTTPS tokens.
forc-pkg/src/source/git · high confidence
Add StorageVec example demonstrating iteration and nested storage
The \examples/storage\_vec\ example now demonstrates the \StorageVec\ collection, showing how to declare storage vectors for single types, enums, and nested structures. It illustrates usage patterns including pushing elements, retrieving values with \get\, and iterating via both \for\ loops (preferred) and \while\ loops for custom traversal logic.
_examples/storage\vec · high confidence
Add Vec usage example to documentation
A new example script has been added to demonstrate the usage of the \Vec\ collection type in Sway. The example covers creating a vector, pushing elements, accessing items with bounds checking, iterating using both \while\ and \for\ loops, handling out-of-bounds access, and storing multiple data types within a single vector using an enum.
examples/vec · high confidence
Add configurable constants example with generic types and string slices
The examples/configurable\constants example now demonstrates defining configurable constants using generic structs and enums, as well as string slices via the new \\_to\_str\_array intrinsic. Users can see how to configure values like StructWithGeneric\<u8\> and EnumWithGeneric\<bool\> alongside basic types, and retrieve them through the TestContract ABI.
_examples/configurable\constants · high confidence
Add example demonstrating ASM tuple return values
A new example has been added to the \examples/asm\_return\_tuple\_pointer\ directory that demonstrates how to return a tuple of values from an ASM block. The \main.sw\ script defines an \adder\ function that uses assembly instructions to compute sums and stores the results into a tuple output, which is then destructured and asserted in the main function.
_examples/asm\_return\_tuple\pointer · high confidence
Add forc-debug client usage example
The forc-debug plugin now includes an example demonstrating how to use the FuelClient for debugging transactions. This example shows how to start a debug session, set breakpoints, execute a transaction, inspect registers and memory, and control execution with single-stepping.
forc-plugins/forc-debug/examples · high confidence
Add identity example demonstrating access control and type conversions
The examples/identity directory now includes a new Sway contract example that illustrates how to use the Identity type for access control and type manipulation. The example shows how to cast a raw address to an Identity, convert an Identity to a ContractId, and handle different execution paths based on whether the Identity represents an Address or a ContractId. It also demonstrates storage-based access control by checking the message sender against a stored owner Identity.
examples/identity · high confidence
Add native asset example contract demonstrating standard library operations
The \examples/native\_asset\ directory now includes a new Sway contract (\main.sw\) that serves as a practical reference for interacting with the standard library's asset module. This example demonstrates core native asset operations including minting, burning, and transferring coins, as well as querying balances for specific contracts and the current contract itself. It also illustrates how to handle payable deposits and retrieve message metadata (amount and asset ID) during execution, providing users with a concrete template for implementing similar functionality in their own contracts.
_examples/native\asset · high confidence
Add ownership example using SRC-5 standard
Added a new example in examples/ownership/src/main.sw that demonstrates the SRC-5 Ownership Standard. The file defines the required State enum and Ownership struct, implements the StorageKey and Ownership interfaces for storage management, and provides a contract ABI with functions to set, revoke, and check ownership, initializing the storage with a zero address.
examples/ownership · high confidence
Add signature verification example for Ed25519, Secp256k1, and Secp256r1
The \examples/signatures\ directory now includes a new \main.sw\ script that demonstrates how to verify and recover public keys, native addresses, and EVM addresses using Ed25519, Secp256k1, and Secp256r1 signatures. This example utilizes the \std::crypto\ and \std::hash\ modules to show practical usage of cryptographic functions for signature verification and address recovery.
examples/signatures · high confidence
Add storage namespace example
The examples/storage\_namespace directory now includes a Solidity-like contract example demonstrating the use of storage namespaces. The example shows how to define a storage block with a specific namespace (example\_namespace) and interact with variables within that namespace using read and write operations.
_examples/storage\_namespace, examples/wallet\_smart\contract · high confidence
Add storage\_map example demonstrating StorageMap usage
The \examples/storage\_map\ directory now contains a new Sway contract example that demonstrates how to declare and use \StorageMap\ for storing key-value pairs. The example shows basic insertion and retrieval using \insert\ and \get\ methods, handling tuple keys, and accessing nested \StorageMap\ structures. It also illustrates the use of \try\_read\ for safe access to potentially missing values.
_examples/storage\map · high confidence
Add syntax highlighting for Sway code in documentation
Users can now see Sway code blocks properly highlighted in the generated documentation (forc doc), the reference book, and the theme assets. This change introduces a new syntax definition for the Sway language (including keywords like \contract\, \storage\, \mod\, and \type\) and integrates it into the highlight.js build process used by the documentation tooling.
scripts/highlightjs · high confidence
Add time example demonstrating duration and timestamp operations
The examples/time directory now includes a new source file that serves as a usage guide for the time library. It demonstrates how to create and manipulate Duration objects using constants and constructor methods, perform arithmetic and comparison operations on durations, and work with Time instances to retrieve current or specific block times, calculate elapsed time, and convert between UNIX timestamps and TAI64 format.
examples/time · high confidence
Add type alias example demonstrating usage and interoperability
Added a new example in \examples/type\_aliases\ that demonstrates how to define and use type aliases in Sway. The example shows creating a \Kilometers\ alias for \u64\ and a \MyArray\ alias for a complex struct array, illustrating how aliases simplify long type signatures and allow interoperability between the alias and its underlying type in arithmetic operations.
_examples/type\aliases · high confidence
Added CEI pattern analysis example
The examples/cei\_analysis directory now contains a Sway contract demonstrating the Check-Effects-Interactions (CEI) pattern. The main contract implements a withdraw function that performs an external call to another contract before updating local storage balances, serving as a reference for safe interaction ordering.
_examples/cei\analysis · high confidence
Added SuperABIs example demonstrating interface inheritance
The examples/abi\_superabis directory now includes a sample contract illustrating how SuperABIs work in Sway. It defines a base ABI (MySuperAbi) and a derived ABI (MyAbi) that inherits from it, showing that implementing the derived ABI requires also satisfying the base ABI's interface.
_examples/abi\superabis · high confidence
Added Sway language support to code highlighting
Developers can now highlight Sway code blocks in documentation and web interfaces. This change introduces a new Prism.js grammar for the Sway language (including keywords, types, and syntax) and provides a build script to generate the minified highlighter file, enabling accurate syntax coloring for Sway source code.
scripts/prism · high confidence
Added enum usage examples
The examples/enums directory now includes source files demonstrating how to define and use enums in the language, including basic definitions, nested enums, enums containing structs, and best practices for error handling.
examples/enums · high confidence
Added example demonstrating a self-implementing wallet smart contract
A new example has been added at \examples/wallet\_smart\_contract\_self\_impl\ that showcases a Sway contract implementing its own ABI. This sample contract allows the owner to receive base asset funds, track the balance in storage, and send those funds to a specified recipient, serving as a reference for self-contained wallet implementations.
_examples/wallet\_smart\_contract\_self\impl · high confidence
Added example demonstrating methods and associated functions
A new example has been added to the \examples/methods\_and\_associated\_functions\ directory that illustrates how to define methods (functions taking \self\) and associated functions (functions not taking \self\, used here as a constructor) on a struct. The example defines a \Foo\ struct with \bar\ and \baz\ fields, implements an \is\_baz\_true\ method and a \new\_foo\ associated function, and demonstrates their usage in the main script.
_examples/methods\_and\_associated\functions · high confidence
Added example demonstrating ref mut parameters
A new example file was added to the repository that demonstrates the usage of \ref mut\ parameters in Sway. The example includes functions that modify primitive integers, tuples, enums, and struct fields by reference, along with a main function that calls these functions to verify the mutations.
_examples/ref\_mut\params · high confidence
Added examples for basic and nested storage variables
New example contracts have been added to demonstrate storage usage. The \basic\_storage\_variables\ example shows how to declare and interact with simple storage types like \u64\, \b256\, \Address\, and \Option\<u8\>\, including writing values and reading them with fallbacks. The \nested\_storage\_variables\ example illustrates working with complex nested structures, specifically \StorageMap\ containing \StorageVec\, \StorageString\, and \StorageBytes\, demonstrating both direct access and key-based access patterns for reading and writing these nested types.
_examples/basic\_storage\_variables, examples/nested\_storage\variables · high confidence
Added multi-contract call example contracts
New example contracts have been added to demonstrate calling multiple contracts within a single transaction. The \caller\ contract includes a test that invokes a method on the \callee\ contract alongside its own method, illustrating how to interact with external contract IDs in unit tests.
_examples/multi\_contract\_calls/callee, examples/multi\_contract\calls/caller · high confidence
Added trait example demonstrating generic trait constraints
The examples/traits directory now includes a new main.sw file that demonstrates defining a generic trait (Convert), implementing it for specific structs (Rectangle converting from Square), and using trait constraints on free functions (into\_rectangle). This serves as a reference for how to use generic traits and where-clauses in Sway.
examples/traits · high confidence
Added tuples example demonstrating declaration, access, and destructuring
The examples/tuples directory now includes a new source file (src/main.sw) that serves as a usage example for the tuples feature. It demonstrates declaring tuples with explicit and inferred types, accessing elements via indexing, destructuring tuples into variables, using wildcards for ignored values, and mutating tuple contents.
examples/tuples · high confidence
Added wallet ABI example library
A new example library demonstrating a wallet ABI has been added to the examples directory. This library defines a Wallet interface with two functions: receive\_funds, which is payable and allows reading and writing storage, and send\_funds, which allows reading and writing storage to transfer a specified amount to a recipient address. This serves as a reference implementation for wallet-related smart contract interactions.
_examples/wallet\abi · high confidence
Added wallet contract caller example script
A new example script has been added to demonstrate how to interact with a wallet contract. The script shows how to instantiate a wallet ABI, define a contract address, and call the \send\_funds\ method to transfer assets to a recipient, including specifying gas and coin parameters.
_examples/wallet\_contract\_caller\script · high confidence
Assembly block support and AST serialization
The \sway-ast\ crate now includes AST definitions for assembly blocks (\AsmBlock\), allowing users to write inline assembly with register declarations and instructions. The \Instruction\ enum defines supported opcodes (such as \add\, \addi\, \and\, \div\, \eq\, \gt\, \lt\, \mlog\, \mod\, etc.) with their respective register and immediate arguments. Additionally, all AST nodes in this module are now serializable via \Serialize\, enabling serialization of the abstract syntax tree.
sway-ast/src/expr · high confidence
Automated bisect script for detecting Sway compiler behavior changes
A new \bisect-forc.sh\ script has been added to automatically identify the specific commit that introduced a change in behavior (such as a compilation success/failure flip) within the Sway compiler. Users can run the script against a Sway project and a specific \forc\ subcommand (defaulting to \build\) to search through git history, using caching to speed up repeated compilations, and it will pinpoint the exact commit where the behavior diverged from the initial state.
scripts/bisect-forc · high confidence
Automated forc command and plugin documentation generation
The mdbook-forc-documenter now functions as an mdbook preprocessor that automatically generates documentation for forc commands and native plugins. It discovers available commands by parsing \forc --help\ and identifies plugins via \forc plugins\, then injects this live help text into the corresponding book chapters. The tool also validates the book structure by warning about or erroring (in strict mode) on missing or dangling documentation entries, ensuring the generated docs stay in sync with the installed toolchain.
scripts/mdbook-forc-documenter/src · high confidence
Automatic implementation of Debug, ABI encoding, and marker traits
The compiler now automatically generates implementations for the \Debug\, \AbiEncode\, \AbiDecode\, \Enum\, and \Error\ traits on user-defined structs and enums. This eliminates the need for manual boilerplate code to serialize types for ABI interactions or to enable debug formatting, as the compiler infers and applies these implementations during semantic analysis.
_sway-core/src/semantic\_analysis/ast\_node/declaration/auto\impl · high confidence
Bootstrap EVM backend assembly generation
The Sway compiler now includes an initial implementation of the EVM (Ethereum Virtual Machine) backend, enabling the generation of EVM-compatible bytecode from Sway source code. This change introduces the \EvmAsmBuilder\ and associated module structures within \sway-core/src/asm\_generation/evm\, establishing the foundational infrastructure for compiling smart contracts to run on EVM-based chains.
_sway-core/src/asm\generation/evm · high confidence
Example demonstrates mutable array element assignment
The arrays example now includes a script showing how to declare a mutable array of booleans and modify individual elements at runtime. This illustrates the capability to mutate array contents, specifically assigning a new value to an existing index.
examples/arrays · high confidence
Example demonstrating ABI supertrait implementation
Added a new example in \examples/abi\_supertraits\ that illustrates how to define an ABI that inherits from a supertrait. The code shows a \MyAbi\ ABI extending \ABIsupertrait\, allowing implementations of \MyAbi\ to call methods defined in the supertrait (e.g., \Self::foo()\), and demonstrates the requirement that implementing \MyAbi\ for a contract also requires implementing the \ABIsupertrait\.
_examples/abi\supertraits · high confidence
Expanded code actions for Sway smart contracts
The Sway language server now offers a comprehensive set of code actions to accelerate development. Users can generate documentation templates for functions, structs, enums, and other declarations, and quickly scaffold \impl\ blocks for structs, enums, and ABIs. A new \new\ function generator is available for structs, and the server can automatically insert missing imports or qualify unknown symbols with their full paths to resolve errors.
sway-lsp · high confidence
Flatten markdown includes in forc-publish
The forc-publish plugin now preprocesses markdown files to flatten nested include directives (e.g., \{{\#include ...}}\). It builds a dependency graph of included files, detects cycles, and expands all includes into a single output string, ensuring that documentation published via forc contains the full, resolved content rather than raw include syntax.
_forc-plugins/forc-publish/src/md\_pre\process · high confidence
Initial DAP server implementation for debugging Sway unit tests
The \forc-debug\ plugin now includes a Debug Adapter Protocol (DAP) server implementation located in \forc-plugins/forc-debug/src/server\. This new server component (\DapServer\) manages the lifecycle of debugging sessions for Sway unit tests, handling standard DAP commands such as setting breakpoints, stepping through code, and evaluating variables. It integrates with the test execution framework to build Sway packages, generate source maps, and report test results (including duration and gas usage) back to the debugger client, enabling interactive debugging of unit tests directly from IDEs that support the DAP standard.
forc-plugins/forc-debug/src/server, forc-plugins/forc-debug/src/server/handlers · high confidence
Initial DWARF debug symbol generation support
The compiler now generates DWARF debug information for Sway programs. This new capability in the debug generation module constructs line number programs from the source map and writes them into ELF sections, enabling debuggers to map compiled code back to original source lines and columns.
_sway-core/src/debug\generation · high confidence
Initial project scaffolding and developer tooling setup
This change establishes the foundational structure for the Sway project, renaming the repository from 'fuel-vm-hll' to 'Sway' and updating the README with comprehensive build and documentation instructions. It introduces a \justfile\ to centralize common development tasks (CI checks, benchmarking, building) and adds a \ci\_checks.sh\ script to run local CI validations. The commit also adds configuration files for Rust tooling (\rustfmt.toml\, \clippy.toml\), a security policy (\SECURITY.md\), and scripts for dependency management (\update\_fuel\_dependencies.sh\) and benchmarking (\benchmark.sh\). Additionally, it configures \.gitattributes\ for syntax highlighting of \.ir\ files and updates \.gitignore\ to exclude generated artifacts, lock files, and benchmark outputs.
(repo-wide) · high confidence
Initial release of the \`forc\` CLI tool
The \forc\ command-line interface is introduced as a new binary, providing core functionality for building and checking Sway projects. The tool exposes \forc build\ and \forc check\ commands, with a modular structure separating CLI logic, operations, and utilities. It supports a test feature for internal testing and integrates with \sway\_utils\ for configuration constants.
forc/src · high confidence
Introduce Query Engine with module, program, and function caching
The \sway-core/src/query\_engine\ module has been added to centralize and optimize compilation caching. It introduces a \QueryEngine\ struct that manages three distinct caches: \programs\_cache\ for storing compiled programs, \module\_cache\ for tracking parsed and typed module information (including namespace modules and dependency hashes), and \function\_cache\ for deduplicating function declarations. These caches are protected by \parking\_lot::RwLock\ via a \CowCache\ wrapper to allow efficient cloning for LSP operations while maintaining thread safety. This change provides the infrastructure for caching and restoring namespace modules, optimizing LSP performance, and enabling garbage collection for cached AST nodes.
_sway-core/src/query\engine · high confidence
Introduce Sway IR crate with SSA-style intermediate representation and optimization pipeline
This change introduces the \sway-ir\ crate, a new library providing an SSA-style intermediate representation for the Sway compiler, modeled after LLVM to simplify the optimization phase. It includes core data structures for modules, functions, blocks, and values, along with analysis passes for call graphs, dominator trees, and memory escape analysis. The crate also provides an \opt\ binary for running optimization passes on IR dumps and an \inspect\ binary for diffing and analyzing IR output from \forc build\, enabling developers to verify and tune compiler optimizations.
sway-ir · high confidence
Introduce \`forc check\` command for fast compilation verification
A new \forc check\ command has been added to the CLI, allowing users to verify the correctness of their Sway code without generating bytecode. This operation performs parsing, type-checking, and dead-code analysis, returning the typed AST and any errors, which provides a faster feedback loop for development compared to a full build.
forc/src/ops · high confidence
Introduce \`forc migrate\` CLI with check, run, and show commands
The \forc-migrate\ tool is now available, providing three new subcommands to manage breaking changes and experimental features. The \forc migrate show\ command lists upcoming breaking change features, their migration steps, and the required experimental feature flags. The \forc migrate check\ command performs a dry-run of migration steps to identify code locations that require review or modification without making changes. The \forc migrate run\ command executes the migration steps, automatically applying code modifications where possible and guiding developers through manual actions for more complex changes.
forc-plugins/forc-migrate/src/cli/commands · high confidence
Introduce \`forc-migrate\` CLI for Sway version upgrades
A new \forc-migrate\ command-line tool is available to help users migrate Sway projects to the next breaking change version. The tool provides three subcommands: \show\ to display required migration steps, \check\ to verify if a project is compatible, and \run\ to execute the migration. It supports compiling packages with experimental features and handles IPFS source resolution, though it currently does not support migrating workspaces (users must migrate each member individually).
forc-plugins/forc-migrate/src/cli · high confidence
Introduce \`forc-migrate\` tool with matching infrastructure and initial migration steps
The \forc-migrate\ tool is introduced to help developers upgrade Sway codebases across breaking changes. This update adds the core matching infrastructure (\matching/lexed\_tree.rs\, \matching/typed\_tree.rs\) for searching and locating elements in lexed and typed ASTs, along with a set of initial migration steps: \merge\_core\_std\ (replacing \core\ with \std\ in paths), \error\_type\ (renaming \panic\ identifiers to \r\#panic\), \new\_hashing\ (reviewing usages of \StorageMap\, \sha256\, and \keccak256\), \partial\_eq\ (handling \Eq\ implementations), and \try\_from\_bytes\_for\_b256\ (migrating \Bytes::into\ to \Bytes::try\_into\). A demo migration is also included for testing the tool's capabilities.
forc-plugins/forc-migrate/src/migrations · high confidence
Introduce centralized experimental feature management
Added a new \sway-features\ crate that centralizes the definition, parsing, and configuration of experimental Sway features. This introduces a structured \Feature\ enum and \ExperimentalFeatures\ struct to manage feature flags, supporting configuration via package manifests, CLI arguments (\--experimental\, \--no-experimental\), and environment variables. The initial set of managed features includes \new\_encoding\, \references\, and \new\_hashing\ (enabled by default), as well as \str\_array\_no\_padding\ and \dynamic\_storage\ (disabled by default), providing a unified mechanism for enabling or disabling these capabilities during compilation.
sway-features · high confidence
Introduce configurable formatting options and comment preservation in swayfmt
The \swayfmt\ formatter now supports a comprehensive configuration system via a \swayfmt.toml\ file, allowing users to customize whitespace (max width, tabs vs spaces, newline styles), imports (grouping, granularity, reordering), item layout (brace styles, blank lines), expressions (brace styles, trailing semicolons, match arm formatting), literals (hex case, string formatting), structures (field alignment, single-line literals), and comments (wrapping, normalization). Additionally, the formatter now preserves comments in their original positions relative to the code structure, ensuring that documentation and inline comments are not lost during formatting.
swayfmt · high confidence
Introduce control flow analysis for return paths and dead code detection
The compiler now performs static analysis to ensure all code paths in functions with a return type actually return a value, emitting a \PathDoesNotReturn\ error if a path is incomplete. Additionally, it detects unused declarations and variables (dead code) by tracing reachability from entry points (such as \main\, public functions, or test functions) and warns on code that is never executed. This analysis covers scripts, predicates, contracts, and libraries, identifying unreachable code and unused parameters or variables to help users clean up their Sway projects.
_sway-core/src/control\_flow\analysis · high confidence
Introduce core Sway type definitions and source management infrastructure
The \sway-types\ crate now provides the foundational types for the Sway language, including \Ident\ and \IdentUnique\ for handling identifiers with span information, \Span\ and \Source\ for source code location tracking, and \SourceEngine\ for managing file paths and source buffers. It also defines \IntegerBits\ for numeric type sizes, \U256\ for 256-bit unsigned integer arithmetic, and utility functions in \style.rs\ for converting identifiers between naming conventions (snake\_case, camelCase, etc.). Additionally, it exposes AST primitives like \Delimiter\ and \PunctKind\, and constants such as \DEFAULT\_FILE\_EXTENSION\ and \LANGUAGE\_NAME\.
sway-types · high confidence
Introduce forc-debug as a library and CLI for Sway debugging
The forc-debug plugin is now available as a reusable library (forc-debug/src/lib.rs) alongside its CLI entry point (main.rs), exposing modules for CLI handling, the debugger engine, error types, register name mapping, and type definitions. This change enables other components to programmatically integrate the debug adapter protocol (DAP) server and CLI logic, while the CLI itself provides a serve mode to start the DAP server and a non-serve mode for direct CLI interaction, with configurable API URL and tracing support. The types module introduces an AbiMap for managing contract ABIs, currently stubbed to return an error until the Sway ABI Registry is implemented.
forc-plugins/forc-debug/src · high confidence
Introduce forc-fmt plugin for Sway code formatting
Adds the \forc-fmt\ plugin, a new tool for formatting Sway source code. Users can now format individual files or entire projects (including workspaces) via the \forc fmt\ command, with support for check mode (\--check\) to verify formatting without modifying files. The plugin integrates with the Sway compiler infrastructure to handle experimental features and provides specific error handling for unsaved files and invalid inputs.
forc-plugins/forc-fmt · high confidence
Introduce forc-lsp binary with Jemalloc allocator
A new \forc-lsp\ binary is introduced as a plugin for the Sway Language Server, executable via \forc lsp\. The implementation initializes the LSP using \sway\_lsp::start()\ and configures the global memory allocator to use Jemalloc (\tikv\_jemallocator\) to improve performance.
forc-plugins/forc-lsp · high confidence
Introduce forc-pkg package management library
The \forc-pkg\ crate is introduced to handle building, locking, fetching, and updating Sway projects as Forc packages. It provides the core infrastructure for managing \Forc.toml\ manifests, resolving dependencies (including git and path sources), and generating \Forc.lock\ files to pin package versions and sources. The library exposes modules for lock file handling, manifest parsing, and source resolution, serving as the foundation for the \forc build\ and \forc check\ commands.
forc-pkg/src · high confidence
Introduce forc-publish plugin for publishing Sway packages to forc.pub
Users can now publish Sway packages to the forc.pub registry using the new forc-publish plugin. The plugin handles authentication by accepting a token via CLI argument, the FORC\_PUB\_TOKEN environment variable, or by prompting the user and saving it to \~/.forc/credentials.toml. It validates the local project (ensuring Forc.toml exists, has a version, and uses version-based dependencies), creates a compressed tarball excluding the /out/ directory, and uploads it to the registry using Server-Sent Events (SSE) for progress updates.
forc-plugins/forc-publish/src · high confidence
Introduce hierarchical lexical scopes and contract ID binding in the namespace module
The namespace module has been restructured to support hierarchical lexical scopes, allowing the compiler to track nested scopes and their relationships more accurately during type checking. A new \LexicalScope\ structure manages symbol resolution, imports, and trait implementations within these scopes. Additionally, a new \contract\_helpers\ module automatically binds the contract ID as a constant in the root module for contract packages, ensuring it is available for use in Sway code. The \Module\ and \Package\ structures now explicitly manage submodules and external dependencies, providing a clearer representation of the project's module hierarchy.
_sway-core/src/semantic\analysis/namespace · high confidence
Introduce in-VM test execution with syscall capture and single-stepping
The \forc-test\ module now executes Sway unit tests directly within an in-memory Fuel VM interpreter rather than relying on external tooling. This change introduces a new \EcalSyscallHandler\ that captures and optionally applies VM syscalls (such as \write\ and \fflush\), enabling accurate logging and output during test runs. The \TestExecutor\ supports single-stepping execution to precisely jump into test functions, and the test result structures now include detailed metadata like gas usage, execution duration, and captured syscall logs, providing users with richer debugging and performance insights.
forc-test/src · high confidence
Introduce modular HTML rendering components for forc-doc item pages
The forc-doc documentation generator now uses a new modular structure in \src/render/item\ to render individual API item pages. This change introduces \ItemHeader\ and \ItemBody\ components that generate the HTML head (including metadata, favicon, and CSS links for the Sway logo, normalize, swaydoc, and Ayu themes) and the main body (including the sidebar, search bar, code declaration block, and expandable description). It also adds \DocumentableType\ to distinguish between declared types and primitives, \Context\ to render item-specific details like struct fields, enum variants, and trait methods, and \type\_anchor\ to generate clickable links for nested types such as enums, structs, arrays, and slices. This refactoring improves the maintainability and structure of the generated HTML documentation.
forc-plugins/forc-doc/src/render/item · high confidence
Introduce registry source support for fetching packages from GitHub-hosted indexes
Added a new registry source implementation in \forc-pkg/src/source/reg\ that allows \forc\ to resolve and fetch packages from a GitHub-hosted index repository (defaulting to \FuelLabs/forc.pub-index\). This feature introduces a \GithubRegistryResolver\ that calculates file locations using configurable chunking and namespace support (flat or domain-based), parses index files containing package metadata (source/ABI CIDs, dependencies, yank status), and enables parallel dependency fetching. The implementation includes logic for handling nested paths, namespace prefixes, and pinned package resolution via IPFS CIDs.
forc-pkg/src/source/reg · high confidence
Introduce type metadata collection for logs and messages
The compiler now includes a new \collect\_types\_metadata\ module that iterates through the typed AST to ensure all types are well-defined before IR generation. This module introduces \LogId\ and \MessageId\ structures to uniquely identify log outputs and SMO (Send Message to Output) messages, respectively. It also defines \TypeMetadata\ to track the types associated with logged expressions and message data, supporting both legacy and new encoding modes via the \encode\_allow\_alias\ function. This change provides the necessary infrastructure for generating ABI hashes for logs and managing message IDs during compilation.
sway-core/src/types · high confidence
Introduces AST modification utilities for forc-migrate
The \forc-migrate\ tool now includes a new \modifying\ module that provides a structured API for building and modifying elements within a Sway lexed tree. This addition introduces \Modifier\ and \New\ wrappers, along with specific implementations for handling attributes (including \cfg\ and doc-comments), expressions, functions, literals, modules, and storage fields, enabling more precise programmatic transformations during migration.
forc-plugins/forc-migrate/src/modifying · high confidence
Introduces control flow graph infrastructure for dead code analysis
Adds the \ControlFlowGraph\ and \ControlFlowNamespace\ modules in \sway-core/src/control\_flow\_analysis/flow\_graph\. This new infrastructure models program execution steps as a graph using the \petgraph\ library, enabling the compiler to track declarations, namespaces, and control flow paths. This structure serves as the foundation for subsequent dead code analysis (DCA) improvements, such as detecting unused variables and fixing DCA warnings for various language constructs.
_sway-core/src/control\_flow\_analysis/flow\graph · high confidence
Introduces forc CLI plugin system and comprehensive build/debug options
The \forc\ CLI now supports external plugins via the \forc-\<name\>\ executable convention, allowing users to extend the command line with custom subcommands discovered in their PATH. The core command set has been expanded to include dependency management (\add\, \remove\, \update\), project scaffolding (\init\, \new\, \template\), and diagnostic tools (\addr2line\, \contract-id\, \predicate-root\, \parse-bytecode\). Build and test commands now expose granular control over output formats (binary, debug/DWARF, hex), build profiles (debug/release), and compiler introspection, including printing AST, DCA graphs, ASM, IR, and bytecode, as well as dumping trait implementations. Global flags for verbosity, silent mode, and log level have been added to standardize output control across all commands.
forc/src/cli · high confidence
Introduction of Sway AST type definitions
The \sway-ast\ crate now defines the Abstract Syntax Tree (AST) structures for Sway types, including path types, tuples, arrays, string slices, pointers, slices, references (mutable and immutable), the never type, and expressions. These definitions are serializable and provide span information for error reporting and tooling.
sway-ast/src/ty · high confidence
Introduction of lexed program and module structures
The Sway compiler now exposes explicit \LexedProgram\ and \LexedModule\ types in the \sway-core/src/language/lexed\ module. These structures represent the state of a program after the lexing stage but before parsing and type-checking, organizing the code into a tree of modules and submodules. This change provides a distinct intermediate representation for the lexed AST, allowing tools and internal processes to access the module hierarchy and annotated content at this specific compilation stage.
sway-core/src/language/lexed · high confidence
Multi-target ASM generation infrastructure for Fuel, EVM, and MidenVM
The \sway-core/src/asm\_generation\ module has been restructured to support compiling Sway programs to multiple virtual machine backends. A new \ProgramABI\ enum and \InstructionSet\ type allow the compiler to generate assembly for Fuel, EVM, and MidenVM targets. The \from\_ir.rs\ module now routes compilation based on the \BuildTarget\ configuration, instantiating specific builders like \FuelAsmBuilder\ or \EvmAsmBuilder\ to handle target-specific instruction lowering and register allocation.
_sway-core/src/asm\generation · high confidence
New DebugWithContext derive macro for structured debugging
The sway-ir-macros crate now provides a \DebugWithContext\ derive macro, allowing users to automatically implement custom debug formatting for structs and enums that respects a provided context. This enables more detailed and context-aware debugging output for Sway IR types without manual implementation.
sway-ir/sway-ir-macros · high confidence
New cargo-generate templates for Rust integration testing
Added three new \cargo-generate\ templates (\sway-test-rs\, \sway-script-test-rs\, and \sway-predicate-test-rs\) that allow developers to quickly scaffold Rust integration test projects for Sway contracts, scripts, and predicates. Each template includes a \build.rs\ script to compile the Sway project via \forc\ before running tests, and a \harness.rs\ file demonstrating how to initialize the local Fuel provider, load the compiled binary, and execute basic assertions using the \fuels-rs\ SDK.
templates · high confidence
New examples for advanced storage variables and struct storage
Added example contracts demonstrating how to use advanced storage types (StorageMap, StorageVec, StorageString, StorageBytes) and struct storage variables in Sway. The new files show how to declare these storage items, perform read/write operations, and handle specific methods like try\_insert, push, set, pop, and write\_slice for managing complex data structures on-chain.
_examples/advanced\_storage\variables · high confidence
New forc CLI commands for project management, testing, and debugging
The \forc\ CLI now includes a comprehensive set of new commands to streamline development workflows. Project scaffolding is handled by \forc init\ (initialize in existing directory) and \forc new\ (create directory and initialize), with support for contracts, scripts, predicates, libraries, and workspaces, as well as template-based creation via \forc template\. Dependency management is now explicit with \forc add\, \forc remove\, and \forc update\ commands, supporting Git, IPFS, and contract dependencies. The build process is enhanced with \forc check\ for fast type-checking without code generation, and \forc clean\ to remove artifacts. Testing is fully supported via \forc test\, which runs Sway unit tests with features like filtering, parallel execution, gas cost reporting, and detailed log/revert output. Debugging capabilities are added through \forc addr2line\ for source mapping and \forc parse-bytecode\ for inspecting compiled bytecode. Additionally, \forc contract-id\ and \forc predicate-root\ allow users to deterministically compute contract IDs and predicate roots, while \forc plugins\ lists available plugins and \forc completions\ generates shell tab-completion scripts.
forc/src/cli/commands · high confidence
New forc-tx CLI plugin for constructing transactions
A new \forc-tx\ plugin has been added to the CLI suite, allowing users to construct Fuel transactions directly from the command line. The tool supports creating both \Script\ transactions (for executing code with input data) and \Create\ transactions (for deploying contracts with bytecode and storage slots). Users can specify gas limits, maturity, witnesses, and detailed input/output structures via flags, with the resulting transaction serialized as pretty-printed JSON to either standard output or a specified file path.
forc-plugins/forc-tx · high confidence
New hashing example demonstrating generic SHA-256, Keccak-256, and custom Hash trait implementations
The examples/hashing directory now includes a new main.sw script that demonstrates how to use the generic sha256 and keccak256 functions with various data types (integers, booleans, strings, tuples, arrays, enums, and structs). It also shows how to implement the Hash trait for custom types like Location, Stats, and Person, including the optimization of is\_hash\_trivial for simpler types.
examples/hashing · high confidence
New language module for core Sway types and structures
The \sway-core/src/language\ module has been introduced to centralize core language definitions. This change adds new types for handling assembly operations (\AsmOp\, \AsmRegister\), function inlining and tracing directives (\Inline\, \Trace\), logical operators (\LazyOp\), and storage access purity (\Purity\). It also defines the \Programs\ struct to manage compilation stages (lexed, parsed, typed) and introduces \CallPath\ and \CallPathTree\ structures to represent and resolve qualified names within the language. Additionally, it includes definitions for literal values, module structures, and visibility controls.
sway-core/src/language · high confidence
New msg\_sender example demonstrating contract identity verification
Added a new example in examples/msg\_sender that shows how to retrieve the message sender using msg\_sender() and verify the caller's identity against a hardcoded owner address using the Identity type.
_examples/msg\sender · high confidence
New performance data extraction and diffing scripts
Added a suite of shell scripts in \scripts/perf\ to automate the collection, comparison, and statistical analysis of performance metrics. \extract-bytecode-sizes.sh\ and \extract-gas-usages.sh\ parse \forc test\ and \forc build\ outputs to generate CSVs of bytecode sizes and gas usages, respectively. \perf-diff.sh\ compares two such CSV files to identify improvements and regressions, outputting results as Markdown or CSV. \perf-diff-stats.sh\ computes summary statistics (count, average, median, min, max) for these diffs, and \perf-diff-latest.sh\ orchestrates the comparison of the most recent performance data files across various categories.
scripts/perf · high confidence
New script to convert CSV data into interactive HTML pivot tables
A new shell script, \scripts/csv2html/csv2html.sh\, has been added to generate HTML reports from CSV files. This tool creates a self-contained HTML page that uses jQuery, Pivottable, D3, C3, and Plotly to render the CSV data as an interactive pivot table with a default line chart view, allowing users to easily visualize tabular data in a browser.
scripts/csv2html · high confidence
New sway-utils crate with constants, helpers, and performance metrics
A new \sway-utils\ library has been introduced, consolidating shared utilities for the Sway toolchain. It provides constants for file names (e.g., \Forc.toml\, \Forc.lock\), directory structures, and storage namespaces. The crate includes helper functions for file system operations, such as finding nested or parent manifest directories and identifying Sway source files. Additionally, it introduces a \MappedStack\ data structure for LIFO-based value retrieval and a \performance\ module containing structs and macros for tracking compilation phase metrics, memory usage, and bytecode size.
sway-utils · high confidence
New tree-visiting infrastructure for code migrations
The \forc-migrate\ tool now includes a new \visiting\ module that provides a common API for traversing lexed and typed Sway AST trees. This infrastructure enables more robust and localized code migrations by allowing visitors to simultaneously inspect and mutate both the source text (lexed tree) and the semantic information (typed tree), while handling invalidation of cached typed elements when the source is modified.
forc-plugins/forc-migrate/src/visiting · high confidence
New type conversion examples added to the converting\_types example
The \examples/converting\_types\ directory now includes a comprehensive set of Sway source files demonstrating how to convert between various primitive types. These examples cover converting unsigned integers (u8, u16, u32, u64, u256) to and from byte arrays and Bytes, converting between b256 and Identity types (Address, ContractId), and converting between string slices and string arrays. The \main.sw\ module orchestrates these submodules, providing users with concrete code snippets for common type conversion patterns.
_examples/converting\types · high confidence
New type-system AST element modules for generics and constraints
The type system now includes dedicated modules for core AST elements: \TypeBinding\ for turbofish type bindings, \TypeArgs\ for generic argument placement, \GenericTypeArgument\ and \GenericConstArgument\ for typed and const generic arguments, \TraitConstraint\ for where-clause and supertrait requirements, and \TypeParameter\ for both type and const generic parameters. These changes provide the foundational structures for handling generic type parameters, const generics, and trait constraints in the compiler's type-checking and namespace resolution phases.
_sway-core/src/type\_system/ast\elements · high confidence
New utility modules for bytecode analysis, file locking, and CLI scaffolding
The \forc-util\ crate now includes several new modules that expand its capabilities. The \bytecode\ module provides functions to parse bytecode files into instructions and compute a stable bytecode ID by hashing the code while excluding the configurables section. The \fs\_locking\ module introduces \PidFileLocking\ to manage advisory file locks (specifically in \.lsp-locks\) with automatic cleanup of stale locks from dead processes, supporting synchronization between the LSP and other tools like \forc-fmt\. The \cli\ module adds a \cli\_examples\ macro to automatically generate help text and unit tests for CLI command parsing. Additionally, \tx\_utils\ adds helpers for formatting and decoding \Log\ and \LogData\ receipts from test runs, and \restricted\ provides validation logic for project and package names.
forc-util · high confidence
Struct field privacy and destructuring examples
The examples/structs module now demonstrates struct field privacy, showing how to define structs with a mix of public and private fields (e.g., StructWithPrivateFields), and illustrates struct destructuring syntax, including nested destructuring for structs, tuples, and mixed structures.
examples/structs · high confidence
Support for IPFS-sourced dependencies
Users can now specify dependencies hosted on IPFS by providing a Content Identifier (CID) in their manifest. The package manager fetches the source code from an IPFS node or gateway, caches it locally, and integrates it into the build process alongside existing source types like git, path, and registry.
forc-pkg/src/source · high confidence
Support for custom build profiles and dependency management in Forc.toml
Users can now define custom build profiles in their Forc.toml to control compilation behavior, including optimization levels, IR/ASM printing, backtrace settings, and profiling metrics. The manifest system also introduces structured dependency modification via \forc add\ and \forc remove\, allowing precise control over package dependencies, sources (git, path, IPFS), and workspace member targeting.
forc-pkg/src/manifest · high confidence
forc-doc refactored into a library with added benchmarks and search support
The forc-doc plugin has been restructured into a library (forc\_doc) with a separate binary entry point, enabling external consumers to use the documentation generation logic programmatically. This change introduces a new benchmark suite (using codspeed\_criterion\_compat) to measure documentation build performance against the standard library, and adds a client-side search index generation feature (search.rs) that creates a JavaScript search index for the generated HTML documentation. The public API exposes core functions like generate\_docs and types such as DocContext and DocResult, while the binary handles asset bundling and optional browser opening.
forc-plugins/forc-doc/src · high confidence
forc-doc static assets for documentation rendering
The forc-doc plugin now includes the necessary static files to render generated documentation in the browser. This adds the Ayu dark theme CSS, the main Swaydoc stylesheet (using Fira Sans and Source Serif 4 fonts), a highlight.js library for code syntax highlighting, and various SVG assets including the Sway logo, a clipboard icon for code copying, and UI toggle icons.
forc-plugins/forc-doc/src/static.files · high confidence
Architecture
AST definitions moved from sway\_parse to sway\_ast
The Abstract Syntax Tree (AST) definitions have been relocated from the \sway\_parse\ crate into the new \sway\_ast\ crate. This change introduces a comprehensive set of new modules in \sway-ast/src\—including \assignable.rs\, \attribute.rs\, \brackets.rs\, \generics.rs\, \intrinsics.rs\, \keywords.rs\, \literal.rs\, \module.rs\, \path.rs\, \pattern.rs\, \punctuated.rs\, \statement.rs\, \submodule.rs\, \token.rs\, and \where\_clause.rs\—to represent the language's syntax structures. These types are now defined as serializable structs and enums (e.g., \Expr\, \Item\, \Pattern\, \Intrinsic\) within \sway\_ast\, making the AST a distinct, reusable component separate from the parsing logic.
sway-ast/src · high confidence
AST definitions moved to sway-ast with serialization support
The AST definitions for Sway items (such as structs, enums, traits, ABIs, functions, and storage) have been moved from the parser into the dedicated \sway-ast\ crate. These structures now derive \Serialize\, enabling them to be serialized to JSON, and implement the \Spanned\ trait to provide accurate source-location information for error reporting and tooling.
sway-ast/src/item · high confidence
Compiler architecture refactored into modular engines and new build configuration
The \sway-core\ compiler has been restructured to improve modularity and performance. A new \Engines\ struct now centralizes access to the type, declaration, parsed declaration, query, and source engines, replacing previous global or scattered state. A new \BuildConfig\ module introduces explicit build targets (Fuel, EVM), optimization levels, and detailed control over IR and ASM output for debugging. The compiler's internal state management is now backed by a thread-safe \ConcurrentSlab\ using \parking\_lot::RwLock\, and a new \ObservabilityEngine\ provides hooks for tracing and method resolution monitoring. Additionally, a \SourceMap\ module has been added to support inverse source mapping for debugging, and a \MetadataManager\ consolidates IR metadata handling for spans, purity, and inline attributes.
sway-core/src · high confidence
Introduce dedicated assembly language IR modules
The compiler's assembly generation layer now uses a dedicated \asm\_lang\ module containing four new files: \allocated\_ops.rs\, \mod.rs\, \virtual\_immediate.rs\, \virtual\_ops.rs\, and \virtual\_register.rs\. These files define the internal intermediate representation for assembly instructions, separating virtual operations (pre-register allocation) from allocated operations (post-register allocation). This includes type-safe wrappers for immediate values (6, 12, 18, and 24-bit) and register types (virtual and constant), ensuring that the compiler's internal opcode definitions remain synchronized with the Fuel VM specification while providing a safer, more structured foundation for code generation.
_sway-core/src/asm\lang · high confidence
New attribute processing module in the compiler transform layer
The \sway-core/src/transform\ module has been introduced to centralize attribute handling. The new \attribute.rs\ file defines the \AttributeArg\ struct and provides methods for validating and extracting typed values (such as strings and booleans) from attribute arguments, while also identifying specific attribute configurations like conditional compilation targets, deprecated notes, and test revert expectations. This module is exposed via \mod.rs\ to support the broader compiler's attribute parsing and transformation logic.
sway-core/src/transform · high confidence
New modular parser implementation for Sway language constructs
The \sway-parse\ crate has been restructured into a modular architecture with dedicated source files for parsing specific language elements, including attributes, brackets, expressions (with ASM block support), generics, and all major item types (structs, enums, traits, impls, ABIs, storage, etc.). This change introduces a new \Parse\ trait implementation for these components, enabling the parser to handle Sway syntax such as doc comments, attributes, ASM opcodes, and type generics through a standardized, recoverable parsing pipeline.
sway-parse · high confidence
New modular semantic analysis architecture
The semantic analysis phase has been restructured into distinct, specialized modules to improve compiler organization and maintainability. This change introduces dedicated files for key analysis stages: \symbol\_collection\_context.rs\ and \symbol\_resolve.rs\ handle the new symbol collection and resolution passes, \method\_lookup.rs\ centralizes method resolution logic, \module.rs\ manages module dependency graphs and evaluation ordering, \node\_dependencies.rs\ handles AST node reordering and recursion detection, \program.rs\ orchestrates the overall type-checking flow, and \match\_expression/mod.rs\ isolates match expression analysis. Additionally, \cei\_pattern\_analysis.rs\ and \coins\_analysis.rs\ provide static analysis for contract security patterns (Checks-Effects-Interactions) and coin payability, respectively. This refactoring separates concerns within the compiler's semantic analysis pipeline.
_sway-core/src/semantic\analysis · high confidence
New modular structure for expression type-checking
The expression type-checking logic in \sway-core\ has been reorganized into a modular structure. The \typed\_expression.rs\ file now acts as a central hub that delegates specific expression types (such as function applications, struct instantiations, and method calls) to dedicated sub-modules, while a new \intrinsic\_function.rs\ file handles the type-checking for all intrinsic operations. This change improves code organization and maintainability without altering the compiler's external behavior.
_sway-core/src/semantic\_analysis/ast\node/expression · high confidence
Refactor IR generation into a modular sub-module structure
The IR generation logic in \sway-core\ has been reorganized from a monolithic structure into a dedicated \ir\_generation\ module with distinct files for specific concerns. This change introduces \compile.rs\ to handle the orchestration of compiling scripts, predicates, and contracts; \function.rs\ to manage the compilation of individual functions and expressions; \const\_eval.rs\ to handle constant expression evaluation; \convert.rs\ for type and literal conversions; \storage.rs\ for storage key generation and slot serialization; \types.rs\ for IR type creation; \purity.rs\ for storage access purity checking; and \lexical\_map.rs\ for managing local symbol scopes. This modularization improves code organization and maintainability of the compiler's backend.
_sway-core/src/ir\generation · high confidence
Refactored Fuel ASM generation into a modular, multi-file architecture
The Fuel assembly generation logic has been reorganized from a monolithic structure into a set of distinct modules within \sway-core/src/asm\_generation/fuel\. This change introduces dedicated files for managing the abstract instruction set (\abstract\_instruction\_set.rs\), register allocation (\allocated\_abstract\_instruction\_set.rs\), liveness analysis (\analyses.rs\), opcode validation for scripts and predicates (\checks.rs\), compiler constants (\compiler\_constants.rs\), and data/globals sections (\data\_section.rs\, \globals\_section.rs\). The main builder logic is now split into \fuel\_asm\_builder.rs\ and \functions.rs\, while program structures are handled in \programs/\. This modularization clarifies the compilation pipeline stages—from IR to abstract ASM, to register allocation, and finally to finalized bytecode—without changing the external behavior of the compiler.
_sway-core/src/asm\generation/fuel · high confidence
Refactored declaration type-checking into modular, phase-separated files
The semantic analysis logic for declarations has been reorganized from a monolithic structure into distinct, modular files (abi, configurable, constant, declaration, enum, function, impl\_trait, storage, struct, trait, type\_alias, variable). This change introduces a strict separation of concerns by implementing dedicated \collect\, \type\_check\, \type\_check\_analyze\, and \type\_check\_finalize\ methods for each declaration type, moving the compiler from a single-pass approach to a multi-phase semantic analysis pipeline. For users, this results in more robust error handling and improved compiler performance, as the new structure allows for better symbol collection, type checking, and finalization isolation across different declaration kinds.
_sway-core/src/semantic\_analysis/ast\node/declaration · high confidence
Refactored match expression analysis into a modular exhaustivity-checking subsystem
The match expression analysis logic has been reorganized into a dedicated \analysis\ module containing specialized components for the exhaustivity and reachability algorithms. This includes a \Pattern\ representation for match arms, a \Matrix\ and \PatStack\ for tracking covered cases, a \ConstructorFactory\ for generating missing patterns, and a \match\_pattern\_variables\ module that detects duplicate variable bindings in scrutinees. This refactoring isolates the core algorithmic logic (modeled after Rust's pattern matching implementation) from the broader type-checking flow, improving maintainability and clarity of the match exhaustivity checks.
_sway-core/src/semantic\_analysis/ast\_node/expression/match\expression/analysis · high confidence
Refactored parsed expression AST into modular sub-files
The parsed expression AST in \sway-core/src/language/parsed/expression\ has been reorganized into separate modules (\asm.rs\, \match\_branch.rs\, \method\_name.rs\, \scrutinee.rs\) to improve code structure. This change introduces specific types for assembly expressions (\AsmExpression\), match branches (\MatchBranch\), method resolution strategies (\MethodName\), and pattern matching scrutinees (\Scrutinee\), while maintaining the core \Expression\ enum and its variants in the main module.
sway-core/src/language/parsed/expression · high confidence
Refactored type unification into a modular subsystem
The type unification logic in the Sway compiler has been reorganized into a dedicated \unify\ sub-module, splitting the implementation into three distinct components: \occurs\_check.rs\ for detecting recursive type references, \unifier.rs\ for performing type equivalence and substitution, and \unify\_check.rs\ for handling type coercion and constraint subset checks. This structural change improves the organization and maintainability of the type system without altering the external compiler behavior.
_sway-core/src/type\system/unify · high confidence
Refactored typed expression type-checking into modular submodules
The type-checking logic for typed expressions in the Sway compiler has been reorganized from a monolithic structure into distinct, dedicated modules for each expression variant. This change introduces separate implementation files for constant expressions, enum and struct instantiation, function and method applications, if-expressions, lazy operators, struct and tuple field/index access, and unsafe downcasts. By splitting these responsibilities, the compiler's semantic analysis phase now handles each expression type in its own isolated file, improving code maintainability and clarity without altering the external language semantics.
_sway-core/src/semantic\_analysis/ast\_node/expression/typed\expression · high confidence
Behavioural changes
Add CI check to prevent forc-fmt panics
A new shell script (scripts/formatter/forc-fmt-check-panic.sh) has been added to the repository to serve as a CI check. This script iterates through all Sway projects (identified by Forc.toml files) and runs forc-fmt on them, specifically checking for any panics in the output. If any panics are detected, the script exits with a non-zero status, ensuring that the formatter does not crash on valid Sway code during continuous integration.
scripts/formatter · high confidence
Enforcement of immutable function parameters
The compiler now rejects function parameters declared as mutable. When type-checking a function signature, the system validates the mutability of each parameter and emits a \MutableParameterNotSupported\ error if a parameter is marked as mutable, ensuring that function arguments remain immutable within the function body.
_sway-core/src/semantic\_analysis/ast\node/declaration/function · high confidence
Introduce Context for parsing state and configurable block tracking
The \to\_parsed\_lang\ module now includes a \Context\ struct that tracks parsing state, including whether a module contains a \configurable\ block, unique suffixes for destructured variables, and the current build target. This context is passed through the parse tree conversion process to support better error handling and deterministic naming for generated identifiers.
_sway-core/src/transform/to\_parsed\lang · high confidence
Introduce forc-documenter as an mdbook preprocessor
The \forc-documenter\ tool is now implemented as an mdbook command-line preprocessor. This change allows Forc command documentation to be automatically generated and integrated into the mdbook build process, replacing previous methods of documentation generation. The binary handles input parsing from mdbook, validates version compatibility, and outputs the processed documentation in JSON format for the renderer.
scripts/mdbook-forc-documenter/src/bin · high confidence
Match expressions are now desugared to if-else chains during type checking
The type-checking phase for \match\ expressions has been refactored to desugar match arms into equivalent \if-else\ chains immediately, rather than preserving the match structure for later stages. This change introduces a new \ReqDeclTree\ to represent pattern requirements and variable bindings, which is then used to generate the conditional logic. As a result, match expressions are now structurally represented as nested \if\ statements with explicit variable declarations and revert calls for non-exhaustive patterns, simplifying subsequent code analysis and optimization passes that can now reuse existing \if\ expression logic.
_sway-core/src/semantic\_analysis/ast\_node/expression/match\expression/typed · high confidence
New Fuel VM assembly optimization passes
The Fuel VM codegen pipeline now includes several new optimization passes in \sway-core/src/asm\_generation/fuel/optimizations\. These include constant propagation (\constant\_propagate.rs\) to replace registers with known values, constant-indexed aggregate access (\const\_indexed\_aggregates.rs\) to optimize load/store immediates, function reordering (\fn\_order.rs\) to reduce call costs, and various redundancy removals (\misc.rs\) such as eliminating dead moves and sequential jumps. A new verification pass (\verify.rs\) ensures register initialization, and a reachability analysis (\reachability.rs\) performs dead code elimination and control flow simplification. These optimizations are applied during the \AbstractInstructionSet::optimize\ phase, with multiple rounds in release builds.
_sway-core/src/asm\generation/fuel/optimizations · high confidence
New interactive CLI debugger with command completion and ABI log decoding
The \forc-debug\ tool now provides a new interactive command-line interface built on \rustyline\, replacing the previous implementation. This new CLI supports command history, tab-completion for commands and file paths, and fuzzy matching for typos. A key behavioral change is the addition of ABI support for decoding log values in transaction receipts; when a transaction is started with an ABI file (either local or mapped to a specific contract ID), the debugger will now display decoded log data alongside the raw receipt information.
forc-plugins/forc-debug/src/cli · high confidence
New utility functions for formatting docstrings and stripping generic type suffixes
The forc-doc rendering utilities now include helpers to format Sway documentation attributes into HTML using comrak, with support for markdown features like strikethrough, tables, and footnotes. A new \create\_preview\ function generates truncated HTML previews of docstrings, respecting header boundaries and character limits. Additionally, a \strip\_generic\_suffix\ utility removes generic type parameters (e.g., converting \Foo\<T\>\ to \Foo\) from type names for cleaner display.
forc-plugins/forc-doc/src/render/util · high confidence
New utility module for Forc project scaffolding defaults
The \forc/src/utils\ module has been introduced to centralize the generation of default files and configurations for new Forc projects. This includes functions to produce standard \Forc.toml\ manifests (with authors, license, and dependency structures), workspace manifests, and skeleton source code for contracts, scripts, libraries, and predicates. It also provides a \ProgramType\ enum to categorize these project types and handles author detection via environment variables or system user information, ensuring consistent project initialization templates.
forc/src/utils · high confidence
Parsed declaration models are restructured into dedicated modules
The parsed declaration types in sway-core are now organized into separate, dedicated modules (abi, configurable, const\_generic, constant, enum, function, impl\_trait, storage, struct, trait, type\_alias, variable). Each module defines its corresponding struct (e.g., AbiDeclaration, ConfigurableDeclaration, FunctionDeclaration) with explicit fields for attributes, spans, visibility, and type arguments, and implements engine-aware equality (EqWithEngines/PartialEqWithEngines) and debugging traits. This change refactors how the compiler represents parsed language constructs internally, improving modularity and consistency across declaration types without altering the external Sway language syntax.
sway-core/src/language/parsed/declaration · high confidence
Refactor ABI generation into dedicated EVM and Fuel modules
The ABI generation logic has been reorganized into separate modules for EVM (\evm\_abi.rs\) and Fuel (\fuel\_abi.rs\) backends, along with a new \abi\_str.rs\ for shared type-string resolution. This change introduces EVM-specific ABI generation that maps Sway types to Solidity-compatible \ethabi\ parameter types (e.g., \uint256\, \Address\) and supports Fuel ABI features like custom ABI names via \\#\[abi\_name\]\ attributes and generic type handling. Users will see distinct ABI outputs tailored to each target platform, with EVM contracts generating standard Solidity ABIs and Fuel contracts generating the Fuel-specific ABI format.
_sway-core/src/abi\generation · high confidence
Refactor forc-doc into a library with new documentation generation logic
The forc-doc plugin has been restructured into a library, introducing a new internal module structure under src/doc that handles the conversion of typed Sway programs into HTML documentation. This change adds a Descriptor system to determine which declarations are documentable and a ModuleInfo system to manage navigation paths and module hierarchy. The core documentation generation logic now processes structs, enums, traits, and ABIs, while also supporting parallel processing via rayon and handling experimental features.
forc-plugins/forc-doc/src/doc · high confidence
Refactor forc-doc rendering into a modular library with workspace support
The forc-doc rendering logic has been reorganized into a library structure under \forc-plugins/forc-doc/src/render\, introducing dedicated modules for handling index pages (\index.rs\), link generation (\link.rs\), search functionality (\search.rs\), and sidebar navigation (\sidebar.rs\). This change adds support for generating workspace-level documentation index pages that list all documented libraries within a workspace, and implements a client-side search feature that filters results based on a \SEARCH\_INDEX\ object. The rendering pipeline now utilizes \rayon\ for parallel processing of documentation items and ensures that doc links are sorted alphabetically and merged correctly to preserve all results when processing parallel outputs.
forc-plugins/forc-doc/src/render · high confidence
Refactor type substitution logic into dedicated module
The type substitution and monomorphization logic has been reorganized into a new \sway-core/src/type\_system/substitute\ module, containing \subst\_map.rs\ and \subst\_types.rs\. This change introduces a \TypeSubstMap\ to manage mappings between source and destination types, including support for const generic materialization and renaming, and defines a \SubstTypes\ trait with a \SubstTypesContext\ to handle the actual type replacement process. This restructuring improves the organization of the type system code and separates substitution concerns from the broader type checking context.
_sway-core/src/type\system/substitute · high confidence
Refactored declaration engine with typed IDs and parent tracking
The declaration engine in sway-core has been restructured to use strongly-typed identifiers (DeclId and ParsedDeclId) instead of generic indices, improving type safety and reducing lookups. The engine now maintains explicit parent-child relationships for declarations, allowing it to trace modified copies (such as monomorphized functions) back to their originals. Additionally, a new DeclMapping mechanism maps trait interface functions to their concrete implementations, and the engine now supports tracking changes via insert\_modified operations.
_sway-core/src/decl\engine · high confidence
Refactored parsed AST module structure and declaration types
The \sway-core/src/language/parsed\ module has been reorganized to improve modularity and support new language features. The \Declaration\ enum now explicitly includes \ConstGenericDeclaration\, \EnumVariantDeclaration\, and \TypeAliasDeclaration\, reflecting the addition of const generics, enum variant handling, and type aliases. The module structure now separates concerns into distinct files for \code\_block\, \declaration\, \include\_statement\, \use\_statement\, \module\, and \program\. Key additions include \IncludeStatement\ for handling module inclusion, \UseStatement\ with support for re-exports and relative paths, and \ParseModule\ with submodule evaluation order and hashing for caching. The \ParseTree\ and \AstNode\ structures remain central but are now integrated with these new declaration types and module handling capabilities.
sway-core/src/language/parsed · high confidence
Refactored semantic analysis into distinct symbol collection and type-checking phases
The semantic analysis pipeline in \sway-core\ has been restructured to separate symbol collection from type checking. The \ast\_node\ module now implements a two-step process: first, \collect\ resolves symbols and populates the namespace, and second, \type\_check\ performs type inference and validation. This change introduces a two-pass type-checking mechanism for code blocks to correctly handle numeric type propagation and variable unification, and adds explicit warnings for unused return values in expressions. Additionally, new \Mode\ and \AbiMode\ enums are introduced to track whether code is being analyzed within an ABI implementation context.
_sway-core/src/semantic\_analysis/ast\node · high confidence
Reworked type system module structure and declaration engine integration
The \sway-core/src/language/ty\ module has been reorganized into a modular structure with dedicated files for AST nodes, code blocks, declarations, expressions, modules, programs, side effects, and variable mutability. This change introduces \TyAstNode\ and \TyCodeBlock\ types that implement \ReplaceDecls\ and \TypeCheckFinalization\ traits, enabling proper propagation of declaration replacements and type-check finalization through the typed AST. The \TyModule\ now provides recursive iteration over submodules and test functions, while \TyProgram\ includes coherence validation and root module validation logic. Side effects are now explicitly modeled with \TySideEffect\ containing \TyIncludeStatement\ and \TyUseStatement\ variants. Variable mutability is represented by a new \VariableMutability\ enum with \Mutable\, \RefMutable\, and \Immutable\ variants. These changes support the broader refactoring of the declaration engine and type-checking pipeline.
sway-core/src/language/ty · high confidence
Reworked typed expression and storage access types
The typed expression types in \sway-core/src/language/ty/expression\ have been restructured. \TyExpression\ and \TyExpressionVariant\ are now defined in dedicated files, with \TyExpressionVariant\ expanded to include new variants such as \FunctionApplication\ (which now carries \ContractCallParams\), \StructFieldAccess\, \TupleElemAccess\, \EnumInstantiation\, \AbiCast\, \Panic\, \Ref\, and \Deref\. A new \TyReassignment\ type supports complex left-hand sides including dereferencing (\DerefAccess\) and element access paths. Storage access is now represented by a dedicated \TyStorageAccess\ type that tracks namespace paths and struct field names. Additionally, new files define \TyAsmRegisterDeclaration\, \ContractCallParams\, and \TyIntrinsicFunctionKind\ to support these expression forms.
sway-core/src/language/ty/expression · high confidence
Rewrite of the Type Engine for improved performance and garbage collection
The type system in sway-core has been rewritten to use a new TypeEngine architecture that significantly improves compilation performance and memory management. This change introduces a garbage collection mechanism that allows unused types to be collected when their associated modules are garbage collected, reducing memory consumption. The engine now uses a ConcurrentSlab for storing type information and implements singleton patterns for shareable types to maximize reuse. Additionally, the new engine supports better handling of const generics, trait constraints, and type unification, leading to more robust type checking and inference.
_sway-core/src/type\system · high confidence
Storage example updated to use new read/write API
The storage example now uses the updated \std::storage::storage\_api\ functions \read\ and \write\ instead of the previous API. The \read\ function returns an \Option\<u64\>\, requiring the implementation to handle the optional value (using \unwrap\_or(0)\ in this case) rather than returning a direct value, aligning with the new storage key RFC.
_examples/storage\example · high confidence
Sway Standard Library v0.72.1 release
The \sway-lib-std\ package has been updated to version 0.72.1. This release includes the \Forc.toml\ manifest, a \README.md\ describing the library's usage and prelude, and a CI script (\forbid-tests.sh\) that enforces the policy of keeping all unit tests in the in-language test directory rather than within the standard library source. The source code introduces or updates core modules including \Address\, \alloc\, \array\_conversions\ (for \b256\, \u16\, \u32\, \u64\, \u256\), \assert\, \asset\, and \asset\_id\, providing foundational types, memory allocation, byte conversion, and asset management functionality for Sway contracts.
sway-lib-std · high confidence
Sway compiler error reporting is restructured with a new expressive diagnostics API
The \sway-error\ crate has been completely rewritten to replace the previous error handling system with a new, structured diagnostics API. This change introduces a \Diagnostic\ type that supports rich, multi-span error messages, including detailed reasons, contextual hints, and actionable help text. The new system separates error definitions into distinct modules for parsing, lexing, type checking, and general compilation errors, while a new \Handler\ manages the collection, scoping, and deduplication of diagnostics. For users, this results in more precise, readable, and helpful compiler error messages that better guide them in fixing issues in their Sway code.
sway-error · high confidence
Sway compiler refactors type declaration structures and enforces const generic restrictions on ABIs
The compiler's internal representation for type-checked declarations has been reorganized into distinct modules (abi, configurable, const\_generic, constant, enum, function, impl\_trait, storage, struct, trait, type\_alias, variable), introducing specific typed declaration structs like TyAbiDecl and TyConfigurableDecl. This change includes a new behavioral restriction: ABIs (contract interfaces) now explicitly forbid the use of const generics in their method signatures and return types, emitting a \ConstGenericNotSupportedHere\ error if detected. Additionally, the storage declaration logic has been updated to support namespace-based field access and stricter privacy checks for struct fields within storage.
sway-core/src/language/ty/declaration · high confidence
Test coverage
Add reduced standard library variants for faster E2E test compilation; Add test fixtures for contract, predicate, and script modules; Added LSP test fixtures for enum and function tokenization; Added LSP token path test fixtures; Added LSP token test fixture for variable usage scenarios; Added benchmark fixture for sway-lsp; Added integration tests for the forc-debug CLI and DAP server; Added local test orchestration script; Added multi-file diagnostics test fixtures; Added test contract for forc-tx; Added test coverage for workspace patch handling; Added test fixture for ABI token generation; Added test fixture for function cache garbage collection; Added test fixture for inlay hints on function parameters; Added test fixture for match scrutinee tokenization; Added test fixture for storage contract garbage collection; Added test fixture for storage tokenization; Added test fixture for struct and enum tokenization; Added test fixture for struct method completion; Added test fixture for unused code diagnostics; Added test fixtures for auto-import functionality; Added test fixtures for constant tokenization; Added test fixtures for forc-doc impl traits and nested subdirectories; Added test fixtures for forc-doc workspace support; Added test fixtures for forc-publish validation; Added test fixtures for module and trait tokenization; Added test fixtures for multi-file runnable detection; Added test fixtures for nested Option types and module references; Added test fixtures for turbofish syntax and impl targets; Added test fixtures for workspace contract and library resolution; Added test library fixture for forc-test filtering; Added test suite for build profile configuration options; Added tests for forc-doc documentation generation; New test macros for Sway formatter validation; New test utility library for Sway LSP.
Dependencies
Add dependency version checking scripts and update SDK templates to fuels v0.77
Added two new CI helper scripts, \check-dep-versions\ and \check-forc-manifest-version\, to validate dependency versions in the project. Updated the Sway project templates (predicate, script, and test) to use the \fuels\ SDK version 0.77, and upgraded the SDK harness test dependencies to \fuel-core\ 0.48, \fuel-core-client\ 0.48.0, \fuel-vm\ 0.66, and \fuels\ 0.77.
(dependencies) · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Baseline
- First survey — no prior run to compare against. CAI 57.
Lenses
- Code Health 58
- Architecture 97
- Maturity 71
- Readiness 62
- Security 47
- Performance 94
Changes since last survey
- 300 commits — 252 feature/other, 48 fixes
By area
- test/src — 116 commits
- sway-core/src — 43 commits
- (root) — 32 commits
- .github/workflows — 18 commits
- forc-plugins/forc-client — 13 commits
- docs/book — 12 commits
- sway-ir/src — 10 commits
- sway-lib-std/src — 8 commits
- forc-pkg/src — 5 commits
- forc-plugins/forc-node — 5 commits
- sway-ir/tests — 5 commits
- forc-plugins/forc-doc — 4 commits
- forc/src — 4 commits
- forc-plugins/forc-migrate — 3 commits
- forc-plugins/forc-publish — 3 commits
- forc-plugins/forc-mcp — 2 commits
- forc-test/src — 2 commits
- sway-types/src — 2 commits
- swayfmt/src — 2 commits
- (repo) — 1 commit
Notable commits
- fix: Add has_changes_scoped! and fix emitting of scoped errors (#7716)
- fix: Bump to 0.71.2 and fix crates.io publish (#7634)
- fix: Fix "Transaction collided" issue when running run_on_node tests (#7461)
- fix: Fix SROA miscompilation issues (#7689)
- fix: Fix SourceEngine cache to refresh buffers after file edits (#7399)
- fix: Fix SROA when loading in multiple blocks (#7694)
- fix: Fix Vec with ZSTs (#7620)
- fix: Fix copy_prop_reverse cycle detection (#7702)
- fix: Fix get_runtime_representation and const-eval of EnumInstantiation (#7692)
- fix: Fix gix-validate advisory ([GHSA redacted]) (#7671)
- fix: Fix memcpyopt to allow multiple passes of optimisations (#7657)
- fix: Fix broken link to test data directory in README (#7266)
- fix: Fix const generics standalone fns (#7292)
- fix: Fix default --gas-costs option to be built-in (#7475)
- fix: Fix default gas costs and add perf diff scripts to storage_benchmarks (#7593)
- fix: Fix forc-fmt empty if-body + else collapsing onto one line (#7628)
- fix: Fix forc-test dependency to include the tx feature (#7239)
- fix: Fix issues in forc add/remove --help (#7558)
- fix: Fix redundant ops (#7636)
- fix: Fix register allocator non-deterministic output across platforms (#7422)
- …and 280 more
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
FuelLabs/sway was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 11 October 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 102ab6cb0378c4e89b2c0679158ffbec41a0b26e — the exact code this score is about.
- Scored under rubric-2026.10.5 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-fe8540b5da9b.