Help us shape the future of Go! Take the 2026 Go Developer Survey

flowbuild

package
v1.6.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package flowbuild implements flow constraint extraction from control flow graphs. This is the core of Phase B that transforms CFG structure into flow.Inputs, the constraint system that the flow solver uses to compute type narrowing.

EXTRACTION PIPELINE

The Run function executes a multi-stage extraction pipeline:

  1. Declarations: Extract type keys, declared types, and module aliases from the CFG. This seeds the initial type information.

  2. Const Propagation: Collect constant assignments and propagate constant values through the CFG for use in branch analysis.

  3. Assignments: Extract type assignments from local declarations, assignments, and function definitions. This captures the flow of types through variables.

  4. Table Mutators: Extract assignments from table mutation operations (table.insert, table.remove, etc.) that modify container types.

  5. Return Classification: Classify return statements for multi-return inference and nil-return detection.

  6. Edge Constraints: Extract type constraints from branch conditions (if, while, for) that narrow types on specific control flow edges.

  7. Call Constraints: Extract OnReturn constraints from function calls that narrow types based on call results (e.g., error returns).

  8. Termination: Mark edges after terminating calls (error(), assert(false)) as unreachable with false conditions.

OUTPUT

The output is a flow.Inputs struct containing all extracted constraints:

  • DeclaredTypes: Symbol to type mappings
  • EdgeConditions: Type constraints on CFG edges
  • ConstValues: Constant value information
  • PredicateLinks: Call-site predicate connections
  • ReturnKinds: Return statement classifications

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MergeCallConstraintsIntoEdges

func MergeCallConstraintsIntoEdges(inputs *flow.Inputs, callConstraints map[cond.EdgeKey]constraint.Condition)

MergeCallConstraintsIntoEdges merges call OnReturn conditions into edge constraints.

func Run

func Run(fc *fbcore.FlowContext) *flow.Inputs

Run executes the complete flow constraint extraction pipeline. It processes the CFG to extract all type constraints that the flow solver needs to compute narrowed types at each program point.

The extraction order is designed to build dependencies incrementally: declarations first, then assignments, then branch conditions. Each stage can use information from previous stages (e.g., const values in branches).

Returns nil if the graph or its CFG is nil.

Types

This section is empty.

Directories

Path Synopsis
Package assign provides flow-sensitive assignment analysis for the type checker.
Package assign provides flow-sensitive assignment analysis for the type checker.
Package cond implements condition constraint extraction for the flow type system.
Package cond implements condition constraint extraction for the flow type system.
Package constprop performs constant propagation for flow analysis.
Package constprop performs constant propagation for flow analysis.
Package base provides shared context types for flowbuild operations.
Package base provides shared context types for flowbuild operations.
Package decl extracts type declarations from function parameters and locals.
Package decl extracts type declarations from function parameters and locals.
Package keyscoll collects table keys from expressions for type inference.
Package keyscoll collects table keys from expressions for type inference.
Package literal handles literal expression type synthesis for flow analysis.
Package literal handles literal expression type synthesis for flow analysis.
Package mutator extracts container mutation operations from call sites.
Package mutator extracts container mutation operations from call sites.
Package numconst handles numeric constant analysis for type inference.
Package numconst handles numeric constant analysis for type inference.
Package path constructs constraint paths from AST expressions.
Package path constructs constraint paths from AST expressions.
Package predicate builds type predicates from comparison expressions.
Package predicate builds type predicates from comparison expressions.
Package resolve provides symbol and type resolution utilities for flow constraint extraction.
Package resolve provides symbol and type resolution utilities for flow constraint extraction.
Package returns extracts return type information from function bodies.
Package returns extracts return type information from function bodies.
Package tblutil provides utilities for table type analysis.
Package tblutil provides utilities for table type analysis.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL