constcheck

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Overview

Package constcheck enforces Lua 5.4's local attributes at compile time: a local declared `<const>` or `<close>` may never be assigned after its declaration. The pass runs unconditionally in the compile pipeline (unlike the type checker it is not gated by `--!nocheck`), matching PUC Lua where assigning to a const local is a syntax-level error.

Only the *assignment* rule is enforced here. The `<close>` attribute's runtime behaviour (calling `__close` at scope exit) is a documented language-level non-goal for now; `<close>` locals get the same no-reassignment protection as `<const>` and are otherwise inert.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(prog *ast.Program) error

Check walks prog and returns an error describing every assignment to a `<const>`/`<close>` local, or nil when the program is clean. Inner functions count: assigning to a captured const upvalue is also an error.

Types

type Errors

type Errors struct {
	Messages []string
}

Errors aggregates every attribute violation found in one Check pass.

func (*Errors) Error

func (e *Errors) Error() string

Jump to

Keyboard shortcuts

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