checker

package
v1.71.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

checker is the static-analysis pass behind `mx check`. Today it catches three classes of bug before the program runs:

  1. undefined identifiers (typos, forgotten imports)
  2. wrong arity on calls to user-defined functions
  3. unused `let` bindings (warnings, not errors)

The checker walks the AST exactly once, maintaining a scope chain that mirrors how the interpreter would build environments at run time. When it visits a route or function body, it pushes a new child scope so locals don't leak into siblings.

The checker doesn't attempt to model values or types — MX is dynamically typed and most useful errors at this layer are about names, not types. A real type system can grow on top later.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Diagnostic

type Diagnostic struct {
	Severity Severity
	Line     int
	Col      int
	Message  string
}

Diagnostic is one issue found during analysis.

func Check

func Check(prog *parser.Program) []Diagnostic

Check runs the analyzer over a parsed program and returns every diagnostic found, in source order.

type Severity

type Severity int

Severity controls whether a diagnostic stops the build.

const (
	SeverityError Severity = iota
	SeverityWarning
)

func (Severity) String

func (s Severity) String() string

Jump to

Keyboard shortcuts

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