module Savi::Compiler::Local

Overview

The Local pass is meant to mark all usage of local variables, and to validate that they are not used before being assigned a value, or after having their binding destroyed by a consume expression.

We rely on the ReferType pass to let us know which identifiers are types, so that we know they are not local variables.

We rely on the Flow pass for control flow analysis to let us know what possible orders of execution we might see for a variable's use sites.

We rely on the Classify pass for knowing when an assignment's value is used, and for avoiding treating identifiers in non-imperative contexts as variables.

This pass does not mutate the Program topology. This pass does not mutate the AST. This pass may raise a compilation error. This pass keeps state at the per-function level. This pass produces output state at the per-function level.

Defined in:

savi/compiler/local.cr