flow

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PersistedInitializerAnalysis

type PersistedInitializerAnalysis struct {
	DependsOnProps            bool
	DependsOnNondeterministic bool
	Sources                   []Source
}

func AnalyzePersistedInitializer

func AnalyzePersistedInitializer(
	fn *ssa.Function,
	initExpr ast.Expr,
	opts PersistedInitializerOptions,
) PersistedInitializerAnalysis

AnalyzePersistedInitializer performs a conservative provenance analysis of a persisted initializer. It is intended for SharedSignal/GlobalSignal initializers and enforces: - no dependence on props (directly or indirectly) - no dependence on non-builtin calls or mutable global state

The analysis is conservative: it may report nondeterminism for calls that are functionally pure, since purity cannot be proven statically in general.

func AnalyzePersistedInitializerCall

func AnalyzePersistedInitializerCall(
	fn *ssa.Function,
	callExpr *ast.CallExpr,
	opts PersistedInitializerOptions,
) (PersistedInitializerAnalysis, bool)

AnalyzePersistedInitializerCall analyzes a persisted allocation call by locating the corresponding SSA call instruction and slicing from the initializer argument.

This is more robust than relying on Function.ValueForExpr for the initializer expression because DebugRefs are not guaranteed for all expressions.

type PersistedInitializerOptions

type PersistedInitializerOptions struct {
	Fset *token.FileSet

	TypesInfo *types.Info

	// CurrentPkgPath is the package path for the SSA function being analyzed.
	// It is used to restrict global var provenance analysis to the current package.
	CurrentPkgPath string

	// GlobalInitExprs maps package vars to their initializer expressions (if any).
	GlobalInitExprs map[string]ast.Expr

	// GlobalVarsMutated marks package vars that are assigned outside their initializer.
	GlobalVarsMutated map[string]bool

	SetupPropsTypes map[string]bool
	PropsParamName  string
}

type SSAIndex

type SSAIndex struct {
	// contains filtered or unexported fields
}

SSAIndex provides SSA-backed lookups needed for dataflow lint rules. It is built once per AnalyzeDir invocation and shared across files.

func BuildSSAIndex

func BuildSSAIndex(pkgs []*packages.Package) (*SSAIndex, error)

func (*SSAIndex) FunctionForFuncLit

func (i *SSAIndex) FunctionForFuncLit(lit *ast.FuncLit) *ssa.Function

type Source

type Source struct {
	Kind   SourceKind
	Pos    token.Position
	Detail string
}

type SourceKind

type SourceKind string
const (
	SourceKindProps   SourceKind = "props"
	SourceKindCall    SourceKind = "call"
	SourceKindGlobal  SourceKind = "global"
	SourceKindUnknown SourceKind = "unknown"
)

Jump to

Keyboard shortcuts

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