lua

package module
v1.5.4 Latest Latest
Warning

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

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

README

go-lua

Heavily modified Fork of gopher-lua. Lua 5.1 VM with integers/bitwise from 5.3, plus a custom flow-sensitive type checker. Optimized for actor runtimes with shared immutable stdlib and low per-state overhead.

go get github.com/wippyai/go-lua

Type Annotations

local x: number = 42
local name: string = "alice"
local items: {number} = {1, 2, 3}
local lookup: {[string]: number} = {a = 1, b = 2}

type Point = {x: number, y: number}
local p: Point = {x = 10, y = 20}

local fn: (number, number) -> number = function(a, b) return a + b end

Generics

local function first<T>(arr: {T}): T?
    return arr[1]
end

local n = first({1, 2, 3})      -- integer?
local s = first({"a", "b"})     -- string?

type Box<T> = {value: T}
local box: Box<string> = {value = "hello"}

Flow Narrowing

The checker tracks types through control flow. After a nil check, the type is narrowed:

local function process(data: {value: number}?)
    if not data then return end
    print(data.value)  -- data is not nil here
end

Works with union types too:

type Exit = {kind: "exit", code: number}
type Message = {kind: "message", text: string}
type Event = Exit | Message

local function handle(e: Event)
    if e.kind == "exit" then
        print(e.code)  -- e is Exit
    else
        print(e.text)  -- e is Message
    end
end

Effects

Functions track side effects. The stdlib is annotated with what each function does — mutations, errors, I/O. This lets the checker understand code like:

assert(x ~= nil)
print(x.field)  -- x narrowed after assert

Running the VM

L := lua.NewState()
defer L.Close()

if err := L.DoString(`print("hello")`); err != nil {
    panic(err)
}

Error Metadata

WrapError and WrapErrorWithLua preserve metadata from wrapped *lua.Error values. For non-*lua.Error chains (for example errors from another package), register a process-wide metadata extractor once:

import (
    "errors"

    lua "github.com/wippyai/go-lua"
)

func init() {
    lua.ConfigureErrorMetadataExtractor(func(err error) *lua.ErrorMetadata {
        for e := err; e != nil; e = errors.Unwrap(e) {
            kindProvider, hasKind := e.(interface{ ErrorKind() string })
            retryProvider, hasRetry := e.(interface{ ErrorRetryable() (bool, bool) })
            detailsProvider, hasDetails := e.(interface{ ErrorDetails() map[string]any })
            if !hasKind && !hasRetry && !hasDetails {
                continue
            }

            meta := &lua.ErrorMetadata{}
            if hasKind {
                meta.Kind = lua.Kind(kindProvider.ErrorKind())
            }
            if hasRetry {
                if b, ok := retryProvider.ErrorRetryable(); ok {
                    v := b
                    meta.Retryable = &v
                }
            }
            if hasDetails {
                meta.Details = detailsProvider.ErrorDetails()
            }
            return meta
        }
        return nil
    })
}

ConfigureErrorMetadataExtractor is one-time (subsequent calls are ignored). For one-off calls, use WrapErrorWithMetadata(err, context, extractor) instead of changing global process state.

Type Checking

import (
    "github.com/ponyruntime/go-lua/compiler/parse"
    "github.com/ponyruntime/go-lua/types"
)

chunk, _ := parse.Parse(reader, "script.lua")
for _, d := range types.CheckChunk(chunk, types.WithStdlib()) {
    fmt.Printf("%s:%d: %s\n", d.Source, d.Line, d.Message)
}

License

MIT — see LICENSE. Based on gopher-lua by Yusuke Inuzuka.

Documentation

Overview

Package lua provides a VM and compiler for Lua in Go.

Index

Constants

View Source
const (
	// BaseLibName is here for consistency; the base functions have no namespace/library.
	BaseLibName = ""
	// LoadLibName is here for consistency; the loading system has no namespace/library.
	LoadLibName = "package"
	// TabLibName is the name of the table Library.
	TabLibName = "table"
	// StringLibName is the name of the string Library.
	StringLibName = "string"
	// MathLibName is the name of the math Library.
	MathLibName = "math"
	// DebugLibName is the name of the debug Library.
	DebugLibName = "debug"
	// CoroutineLibName is the name of the coroutine Library.
	CoroutineLibName = "coroutine"
	// Utf8LibName is the name of the utf8 Library.
	Utf8LibName = "utf8"
	// ErrorsLibName is the name of the errors Library.
	ErrorsLibName = "errors"
)
View Source
const (
	OP_MOVE     int = iota /*      A B     R(A) := R(B)                            */
	OP_MOVEN               /*      A B     R(A) := R(B); followed by R(C) MOVE ops */
	OP_LOADK               /*     A Bx    R(A) := Kst(Bx)                          */
	OP_LOADBOOL            /*  A B C   R(A) := (Bool)B; if (C) pc++                */
	OP_LOADNIL             /*   A B     R(A) := ... := R(B) := nil                 */
	OP_GETUPVAL            /*  A B     R(A) := UpValue[B]                          */

	OP_GETGLOBAL  /* A Bx    R(A) := Gbl[Kst(Bx)]                            */
	OP_GETTABLE   /*  A B C   R(A) := R(B)[RK(C)]                             */
	OP_GETTABLEKS /*  A B C   R(A) := R(B)[RK(C)] ; RK(C) is constant string */

	OP_SETGLOBAL  /* A Bx    Gbl[Kst(Bx)] := R(A)                            */
	OP_SETUPVAL   /*  A B     UpValue[B] := R(A)                              */
	OP_SETTABLE   /*  A B C   R(A)[RK(B)] := RK(C)                            */
	OP_SETTABLEKS /*  A B C   R(A)[RK(B)] := RK(C) ; RK(B) is constant string */

	OP_NEWTABLE /*  A B C   R(A) := {} (size = BC)                         */

	OP_SELF /*      A B C   R(A+1) := R(B); R(A) := R(B)[RK(C)]             */

	OP_ADD  /*       A B C   R(A) := RK(B) + RK(C)                           */
	OP_SUB  /*       A B C   R(A) := RK(B) - RK(C)                           */
	OP_MUL  /*       A B C   R(A) := RK(B) * RK(C)                           */
	OP_DIV  /*       A B C   R(A) := RK(B) / RK(C)                           */
	OP_MOD  /*       A B C   R(A) := RK(B) % RK(C)                           */
	OP_POW  /*       A B C   R(A) := RK(B) ^ RK(C)                           */
	OP_IDIV /*       A B C   R(A) := RK(B) // RK(C)                          */
	OP_BAND /*       A B C   R(A) := RK(B) & RK(C)                           */
	OP_BOR  /*       A B C   R(A) := RK(B) | RK(C)                           */
	OP_BXOR /*       A B C   R(A) := RK(B) ~ RK(C)                           */
	OP_SHL  /*       A B C   R(A) := RK(B) << RK(C)                          */
	OP_SHR  /*       A B C   R(A) := RK(B) >> RK(C)                          */
	OP_UNM  /*       A B     R(A) := -R(B)                                   */
	OP_BNOT /*       A B     R(A) := ~R(B)                                   */
	OP_NOT  /*       A B     R(A) := not R(B)                                */
	OP_LEN  /*       A B     R(A) := length of R(B)                          */

	OP_CONCAT /*    A B C   R(A) := R(B).. ... ..R(C)                       */

	OP_JMP /*       sBx     pc+=sBx                                 */

	OP_EQ /*        A B C   if ((RK(B) == RK(C)) ~= A) then pc++            */
	OP_LT /*        A B C   if ((RK(B) <  RK(C)) ~= A) then pc++            */
	OP_LE /*        A B C   if ((RK(B) <= RK(C)) ~= A) then pc++            */

	OP_TEST    /*      A C     if not (R(A) <=> C) then pc++                   */
	OP_TESTSET /*   A B C   if (R(B) <=> C) then R(A) := R(B) else pc++     */

	OP_CALL     /*      A B C   R(A) ... R(A+C-2) := R(A)(R(A+1) ... R(A+B-1)) */
	OP_TAILCALL /*  A B C   return R(A)(R(A+1) ... R(A+B-1))              */
	OP_RETURN   /*    A B     return R(A) ... R(A+B-2)      (see note)      */

	OP_FORLOOP /*   A sBx   R(A)+=R(A+2);
	     if R(A) <?= R(A+1) then { pc+=sBx; R(A+3)=R(A) }*/
	OP_FORPREP /*   A sBx   R(A)-=R(A+2); pc+=sBx                           */

	OP_TFORLOOP /*  A C     R(A+3) ... R(A+3+C) := R(A)(R(A+1) R(A+2));
	    if R(A+3) ~= nil then { pc++; R(A+2)=R(A+3); }  */
	OP_SETLIST /*   A B C   R(A)[(C-1)*FPF+i] := R(A+i) 1 <= i <= B        */

	OP_CLOSE   /*     A       close all variables in the stack up to (>=) R(A)*/
	OP_CLOSURE /*   A Bx    R(A) := closure(KPROTO[Bx] R(A) ... R(A+n))  */

	OP_VARARG /*     A B     R(A) R(A+1) ... R(A+B-1) = vararg            */

	OP_NOP /* NOP */

	OP_LOADTYPE /*  A Bx    R(A) := Type(Bx) (lookup by name)                 */
)
View Source
const EnvironIndex = -10001
View Source
const FramesPerSegment = 8

FramesPerSegment should be a power of 2 constant for performance reasons. It will allow the go compiler to change the divs and mods into bitshifts. Max is 256 due to current use of uint8 to count how many frames in a segment are used.

View Source
const GlobalsIndex = -10002
View Source
const LNumberBit = 64
View Source
const MultRet = -1
View Source
const PackageName = "GopherLua"
View Source
const PackageVersion = "0.2 Wippy Edition"
View Source
const RegistryIndex = -10000
View Source
const VarArgIsVarArg uint8 = 2
View Source
const Version = "Lua 5.3 - Wippy Modification"

Variables

View Source
var (
	LTypeNil     = &LType{inner: typ.Nil, name: "nil"}
	LTypeBoolean = &LType{inner: typ.Boolean, name: "boolean"}
	LTypeNumber  = &LType{inner: typ.Number, name: "number"}
	LTypeInteger = &LType{inner: typ.Integer, name: "integer"}
	LTypeString  = &LType{inner: typ.String, name: "string"}
	LTypeAny     = &LType{inner: typ.Any, name: "any"}
	LTypeUnknown = &LType{inner: typ.Unknown, name: "unknown"}
	LTypeNever   = &LType{inner: typ.Never, name: "never"}
)

Primitive type singletons - zero allocation for common types

View Source
var CallStackSize = 128
View Source
var DirSep string
View Source
var ExecDir = "!"
View Source
var FieldsPerFlush = 50
View Source
var IgMark = "-"
View Source
var LDir string // todo: drop it
View Source
var LFalse = LBool(false)
View Source
var LNil = LValue(&LNilType{})
View Source
var LTrue = LBool(true)
View Source
var MaxArrayIndex = 67108864
View Source
var MaxTableGetLoop = 100
View Source
var PathDefault string
View Source
var PathEnvVar = "LUA_PATH"
View Source
var PathMark = "?"
View Source
var PathSep = ";"
View Source
var RegistryGrowStep = 32
View Source
var RegistryMaxSize = 256 * 256
View Source
var RegistrySize = 256

Functions

func ConfigureErrorMetadataExtractor added in v1.5.4

func ConfigureErrorMetadataExtractor(extractor ErrorMetadataExtractor)

ConfigureErrorMetadataExtractor sets the process-wide error metadata extractor once. Subsequent calls are ignored.

func IsErrorKind

func IsErrorKind(err error, kind Kind) bool

IsErrorKind checks if an error matches a specific kind.

func IsIntegerValue

func IsIntegerValue(v LNumber) bool

IsIntegerValue checks if the runtime LNumber value has no fractional part.

func LVAsBool

func LVAsBool(v LValue) bool

LVAsBool returns false if a given LValue is a nil or false otherwise true.

func LVAsString

func LVAsString(v LValue) string

LVAsString returns string representation of a given LValue if the LValue is a string, number, or Error, otherwise an empty string.

func LVCanConvToString

func LVCanConvToString(v LValue) bool

LVCanConvToString returns true if a given LValue is a string, number, or Error otherwise false.

func LVIsFalse

func LVIsFalse(v LValue) bool

LVIsFalse returns true if a given LValue is a nil or false otherwise false.

func OpenBase

func OpenBase(L *LState) int

func OpenCoroutine

func OpenCoroutine(L *LState) int

func OpenDebug

func OpenDebug(L *LState) int

func OpenErrors

func OpenErrors(L *LState) int

OpenErrors registers the errors module and error metatable.

func OpenMath

func OpenMath(L *LState) int

func OpenPackage

func OpenPackage(L *LState) int

func OpenString

func OpenString(L *LState) int

func OpenTable

func OpenTable(L *LState) int

func OpenUtf8

func OpenUtf8(L *LState) int

func RegisterErrorMetatable

func RegisterErrorMetatable(L *LState)

RegisterErrorMetatable registers the cached error metatable for this LState. This must be called once per LState to enable error methods like :kind().

func ReleaseSpawnRequest

func ReleaseSpawnRequest(sr *SpawnRequest)

ReleaseSpawnRequest returns a SpawnRequest to the pool.

func SetErrorMetadataExtractor added in v1.5.4

func SetErrorMetadataExtractor(extractor ErrorMetadataExtractor)

SetErrorMetadataExtractor overrides the process-wide extractor. This is primarily intended for tests.

func SetErrorMetatable

func SetErrorMetatable(L *LState, e *Error)

SetErrorMetatable sets the error metatable on an Error value.

func TypeEquals

func TypeEquals(a, b *LType) bool

TypeEquals checks structural equality of two types.

func TypeIsSubtype

func TypeIsSubtype(a, b *LType) bool

TypeIsSubtype checks if a is a subtype of b.

func UpvalueIndex

func UpvalueIndex(i int) int

Types

type ApiError

type ApiError struct {
	Type       ApiErrorType
	Object     LValue
	StackTrace string
	// Underlying error. This attribute is set only if the Type is ApiErrorFile or ApiErrorSyntax
	Cause error
}

func (*ApiError) Error

func (e *ApiError) Error() string

func (*ApiError) String

func (e *ApiError) String() string

type ApiErrorType

type ApiErrorType int
const (
	ApiErrorSyntax ApiErrorType = iota
	ApiErrorFile
	ApiErrorRun
	ApiErrorError
	ApiErrorPanic
)

type CompileError

type CompileError struct {
	Line    int
	Message string
	// contains filtered or unexported fields
}

func (*CompileError) Error

func (e *CompileError) Error() string

func (*CompileError) String

func (e *CompileError) String() string

type CompileOptions added in v1.5.2

type CompileOptions struct {
	TypeInfo  []byte
	TypeNames map[string]struct{}
}

CompileOptions configures compile-time type resolution for type calls.

TypeInfo should contain the encoded manifest bytes. When provided, its type names are added to the compile-time type name set and stored on the proto. TypeNames can be used to supply additional compile-time type names directly.

type DbgCall

type DbgCall struct {
	Name string
	Pc   int
}

type DbgLocalInfo

type DbgLocalInfo struct {
	Name    string
	StartPc int
	EndPc   int
}

type Debug

type Debug struct {
	Name            string
	What            string
	Source          string
	CurrentLine     int
	NUpvalues       int
	LineDefined     int
	LastLineDefined int
	// contains filtered or unexported fields
}

type Error

type Error struct {
	Err      error       // Wrapped error (error chain)
	Message  string      // Error message
	LuaStack *StackTrace // Lua stack at wrap point

	Context string // Context description
	// contains filtered or unexported fields
}

Error is the unified error type for go-lua. It implements both error and LValue interfaces. Behaves like a string for concatenation and tostring().

func AsError

func AsError(v LValue) (*Error, bool)

AsError extracts an Error from an LValue if possible.

func GetError

func GetError(err error) *Error

GetError extracts a *Error from an error chain using errors.As. Returns nil if no *Error is found in the chain.

func NewError

func NewError(message string) *Error

NewError creates a new error with the given message.

func NewErrorf

func NewErrorf(format string, args ...any) *Error

NewErrorf creates a new error with formatted message.

func NewLuaError

func NewLuaError(L *LState, message string) *Error

NewLuaError creates an Error and sets up its metatable.

func WrapError

func WrapError(err error, context string) *Error

WrapError wraps an existing Go error with context.

func WrapErrorWithLua

func WrapErrorWithLua(l *LState, err error, context string) *Error

WrapErrorWithLua wraps an error, captures Lua stack trace, and sets the error metatable.

func WrapErrorWithMetadata added in v1.5.4

func WrapErrorWithMetadata(err error, context string, extractor ErrorMetadataExtractor) *Error

WrapErrorWithMetadata wraps an error with an explicit metadata extractor.

func (*Error) Details

func (e *Error) Details() map[string]any

Details returns structured metadata about the error.

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface.

func (*Error) Kind

func (e *Error) Kind() Kind

Kind returns the error category.

func (*Error) Retryable

func (e *Error) Retryable() Ternary

Retryable returns whether the operation should be retried.

func (*Error) Stack

func (e *Error) Stack() string

Stack returns a formatted stack trace including both Lua and Go stacks.

func (*Error) String

func (e *Error) String() string

String implements LValue - returns the message for tostring() and concat.

func (*Error) Type

func (e *Error) Type() LValueType

Type implements LValue - returns LTUserData.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the underlying error for errors.Is/As support.

func (*Error) WithContext

func (e *Error) WithContext(ctx string) *Error

WithContext adds context description.

func (*Error) WithDetails

func (e *Error) WithDetails(d map[string]any) *Error

WithDetails sets structured metadata.

func (*Error) WithKind

func (e *Error) WithKind(k Kind) *Error

WithKind sets the error category.

func (*Error) WithRetryable

func (e *Error) WithRetryable(r bool) *Error

WithRetryable sets the retry status.

type ErrorMetadata added in v1.5.4

type ErrorMetadata struct {
	Kind      Kind
	Retryable *bool
	Details   map[string]any
}

ErrorMetadata is portable metadata extracted from a Go error chain.

type ErrorMetadataExtractor added in v1.5.4

type ErrorMetadataExtractor func(err error) *ErrorMetadata

ErrorMetadataExtractor extracts metadata from an error chain.

type FunctionProto

type FunctionProto struct {
	SourceName         string
	LineDefined        int
	LastLineDefined    int
	NumUpvalues        uint8
	NumParameters      uint8
	IsVarArg           uint8
	NumUsedRegisters   uint8
	Code               []uint32
	Constants          []LValue
	FunctionPrototypes []*FunctionProto

	DbgSourcePositions []int
	DbgLocals          []*DbgLocalInfo
	DbgCalls           []DbgCall
	DbgUpvalues        []string

	// TypeInfo holds encoded type manifest for this module.
	// Use types/io.EncodeManifest/DecodeManifest to work with this data.
	// Stored on the root FunctionProto and propagated to nested functions.
	TypeInfo []byte
	// contains filtered or unexported fields
}

func Compile

func Compile(chunk []ast.Stmt, name string) (proto *FunctionProto, err error)

func CompileReader

func CompileReader(reader io.Reader, name string) (*FunctionProto, error)

CompileReader compiles Lua source from a reader to bytecode.

func CompileString

func CompileString(source, name string) (*FunctionProto, error)

CompileString compiles Lua source code to bytecode without requiring an LState. The returned FunctionProto can be reused across multiple LStates.

func CompileWithOptions added in v1.5.2

func CompileWithOptions(chunk []ast.Stmt, name string, opts CompileOptions) (proto *FunctionProto, err error)

CompileWithOptions compiles Lua source with compile-time type call resolution.

func (*FunctionProto) GetTypeInfo

func (fp *FunctionProto) GetTypeInfo() []byte

GetTypeInfo returns the encoded type manifest bytes.

func (*FunctionProto) RebuildStringConstants

func (fp *FunctionProto) RebuildStringConstants()

RebuildStringConstants rebuilds the stringConstants cache from Constants. This is needed after deserializing bytecode since stringConstants is not serialized. The stringConstants slice has the same length as Constants - each entry is either the string value (if Constants[i] is LString) or empty string (otherwise).

func (*FunctionProto) SetTypeInfo

func (fp *FunctionProto) SetTypeInfo(data []byte)

SetTypeInfo sets the encoded type manifest bytes.

func (*FunctionProto) String

func (fp *FunctionProto) String() string

type Global

type Global struct {
	MainThread    *LState
	CurrentThread *LState
	Registry      *LTable
	Global        *LTable

	// Owner is the host process/context that owns this Lua VM.
	// Set by the host runtime for fast access from modules.
	Owner any
	// contains filtered or unexported fields
}

type Kind

type Kind string

Kind categorizes errors semantically.

const (
	Unknown          Kind = ""
	NotFound         Kind = "NotFound"
	AlreadyExists    Kind = "AlreadyExists"
	Invalid          Kind = "Invalid"
	PermissionDenied Kind = "PermissionDenied"
	Unavailable      Kind = "Unavailable"
	Internal         Kind = "Internal"
	Canceled         Kind = "Canceled"
	Conflict         Kind = "Conflict"
	Timeout          Kind = "Timeout"
	RateLimited      Kind = "RateLimited"
)

func GetErrorKind

func GetErrorKind(err error) Kind

GetErrorKind extracts the kind from an error.

func (Kind) String

func (k Kind) String() string

type LBool

type LBool bool

func (LBool) Bool

func (bl LBool) Bool() bool

Make LBool implement booler for validate package

func (LBool) String

func (bl LBool) String() string

func (LBool) Type

func (bl LBool) Type() LValueType

type LFunction

type LFunction struct {
	IsG       bool
	Env       *LTable
	Proto     *FunctionProto
	GFunction LGFunction
	Upvalues  []*Upvalue
}

func (*LFunction) LocalName

func (fn *LFunction) LocalName(regno, pc int) (string, bool)

func (*LFunction) String

func (fn *LFunction) String() string

func (*LFunction) Type

func (fn *LFunction) Type() LValueType

type LGContinuation

type LGContinuation func(L *LState, ctx any, status ResumeState) int

LGContinuation is the type for Go function continuations after yield. ctx is user-defined context passed through yield, status is the resume result.

type LGFunction

type LGFunction func(*LState) int

LGFunction is the Go function signature for Lua-callable functions.

type LGoFunc

type LGoFunc LGFunction

LGoFunc is a stateless Go function that can be shared across all LStates. Unlike LFunction, it requires no per-state allocation and can be stored directly in tables or globals without wrapping.

Performance: LGoFunc avoids the LFunction allocation overhead and pointer indirection through Fn.GFunction. For modules that don't need upvalues or environments, using LGoFunc provides better performance.

TODO: Refactor all go-lua internal code to use LGoFunc natively: - Migrate internal libs (baselib, stringlib, mathlib, tablelib, etc.) to use LGoFunc - Simplify callFrame to primarily use GoFunc, remove Fn.IsG complexity - Update pushCallFrame, initCallFrame to assume GoFunc is the default - Remove legacy LFunction wrapping code and pinning state hacks - Update public API (SetGlobal, PreloadModule, etc.) to prefer LGoFunc This would eliminate the dual code paths in VM and simplify maintenance.

func (LGoFunc) String

func (gf LGoFunc) String() string

func (LGoFunc) Type

func (gf LGoFunc) Type() LValueType

type LInteger

type LInteger int64

func (LInteger) Int64

func (i LInteger) Int64() int64

Make LInteger implement int64er for validate package

func (LInteger) String

func (i LInteger) String() string

func (LInteger) Type

func (i LInteger) Type() LValueType

type LNilType

type LNilType struct{}

func (*LNilType) String

func (nl *LNilType) String() string

func (*LNilType) Type

func (nl *LNilType) Type() LValueType

type LNumber

type LNumber float64

func LVAsNumber

func LVAsNumber(v LValue) LNumber

LVAsNumber tries to convert a given LValue to a number.

func (LNumber) Float64

func (nm LNumber) Float64() float64

Make LNumber implement float64er for validate package

func (LNumber) Format

func (nm LNumber) Format(f fmt.State, c rune)

Format implements the fmt.Formatter interface.

func (LNumber) String

func (nm LNumber) String() string

func (LNumber) Type

func (nm LNumber) Type() LValueType

type LState

type LState struct {
	G       *Global
	Parent  *LState
	Env     *LTable
	Panic   func(*LState)
	Dead    bool
	Options Options
	// contains filtered or unexported fields
}

func NewState

func NewState(opts ...Options) *LState

func (*LState) ArgError

func (ls *LState) ArgError(n int, message string)

func (*LState) Call

func (ls *LState) Call(nargs, nret int)

func (*LState) CallByParam

func (ls *LState) CallByParam(cp P, args ...LValue) error

func (*LState) CallK

func (ls *LState) CallK(nargs, nret int, cont LGContinuation, ctx any)

CallK calls a function with a continuation for yield support. If the called function yields, the continuation will be called on resume instead of returning to the caller. The continuation receives the LState, user context, and resume status.

func (*LState) CallMeta

func (ls *LState) CallMeta(obj LValue, event string) LValue

func (*LState) CheckAny

func (ls *LState) CheckAny(n int) LValue

func (*LState) CheckBool

func (ls *LState) CheckBool(n int) bool

func (*LState) CheckFunction

func (ls *LState) CheckFunction(n int) *LFunction

func (*LState) CheckInt

func (ls *LState) CheckInt(n int) int

func (*LState) CheckInt64

func (ls *LState) CheckInt64(n int) int64

func (*LState) CheckNumber

func (ls *LState) CheckNumber(n int) LNumber

func (*LState) CheckOption

func (ls *LState) CheckOption(n int, options []string) int

func (*LState) CheckString

func (ls *LState) CheckString(n int) string

func (*LState) CheckTable

func (ls *LState) CheckTable(n int) *LTable

func (*LState) CheckThread

func (ls *LState) CheckThread(n int) *LState

func (*LState) CheckType

func (ls *LState) CheckType(n int, typ LValueType)

func (*LState) CheckTypes

func (ls *LState) CheckTypes(n int, typs ...LValueType)

func (*LState) CheckUserData

func (ls *LState) CheckUserData(n int) *LUserData

func (*LState) Close

func (ls *LState) Close()

Close returns the state to pool if appropriate.

func (*LState) Concat

func (ls *LState) Concat(values ...LValue) string

func (*LState) Context

func (ls *LState) Context() context.Context

Context returns the LState's context. To change the context, use WithContext.

func (*LState) CreateTable

func (ls *LState) CreateTable(acap, hcap int) *LTable

func (*LState) DoFile

func (ls *LState) DoFile(path string) error

func (*LState) DoString

func (ls *LState) DoString(source string) error

func (*LState) Equal

func (ls *LState) Equal(lhs, rhs LValue) bool

func (*LState) Error

func (ls *LState) Error(lv LValue, level int)

Error is equivalent to lua_error( http://www.lua.org/manual/5.1/manual.html#lua_error ).

func (*LState) FindTable

func (ls *LState) FindTable(obj *LTable, n string, size int) LValue

func (*LState) ForEach

func (ls *LState) ForEach(tb *LTable, cb func(LValue, LValue))

func (*LState) GPCall

func (ls *LState) GPCall(fn LGFunction, data LValue) error

func (*LState) Get

func (ls *LState) Get(idx int) LValue

func (*LState) GetField

func (ls *LState) GetField(obj LValue, skey string) LValue

func (*LState) GetGlobal

func (ls *LState) GetGlobal(name string) LValue

func (*LState) GetInfo

func (ls *LState) GetInfo(what string, dbg *Debug, fn LValue) (LValue, error)

func (*LState) GetLocal

func (ls *LState) GetLocal(dbg *Debug, no int) (string, LValue)

func (*LState) GetMetaField

func (ls *LState) GetMetaField(obj LValue, event string) LValue

func (*LState) GetMetatable

func (ls *LState) GetMetatable(obj LValue) LValue

func (*LState) GetStack

func (ls *LState) GetStack(level int) (*Debug, bool)

func (*LState) GetTable

func (ls *LState) GetTable(obj LValue, key LValue) LValue

func (*LState) GetTop

func (ls *LState) GetTop() int

func (*LState) GetTypeMetatable

func (ls *LState) GetTypeMetatable(typ string) LValue

func (*LState) GetUpvalue

func (ls *LState) GetUpvalue(fn *LFunction, no int) (string, LValue)

func (*LState) Insert

func (ls *LState) Insert(value LValue, index int)

func (*LState) IsClosed

func (ls *LState) IsClosed() bool

func (*LState) LessThan

func (ls *LState) LessThan(lhs, rhs LValue) bool

func (*LState) Load

func (ls *LState) Load(reader io.Reader, name string) (*LFunction, error)

func (*LState) LoadFile

func (ls *LState) LoadFile(path string) (*LFunction, error)

func (*LState) LoadProto

func (ls *LState) LoadProto(proto *FunctionProto) *LFunction

LoadProto creates an LFunction from a precompiled FunctionProto. This is much faster than Load() since it skips parsing and compilation.

func (*LState) LoadString

func (ls *LState) LoadString(source string) (*LFunction, error)

func (*LState) NewClosure

func (ls *LState) NewClosure(fn LGFunction, upvalues ...LValue) *LFunction

func (*LState) NewFunction

func (ls *LState) NewFunction(fn LGFunction) *LFunction

func (*LState) NewFunctionFromProto

func (ls *LState) NewFunctionFromProto(proto *FunctionProto) *LFunction

func (*LState) NewTable

func (ls *LState) NewTable() *LTable

func (*LState) NewThread

func (ls *LState) NewThread() (*LState, context.CancelFunc)

NewThread creates a new coroutine thread with a cancellable context. Returns the thread and a cancel function that should be called when done.

func (*LState) NewThreadWithContext

func (ls *LState) NewThreadWithContext(ctx context.Context) *LState

NewThreadWithContext returns a new LState with the given context. Pass nil for no context (faster execution without cancellation checks).

func (*LState) NewTypeMetatable

func (ls *LState) NewTypeMetatable(typ string) *LTable

func (*LState) NewUserData

func (ls *LState) NewUserData() *LUserData

func (*LState) Next

func (ls *LState) Next(tb *LTable, key LValue) (LValue, LValue)

func (*LState) ObjLen

func (ls *LState) ObjLen(v1 LValue) int

func (*LState) OpenLibs

func (ls *LState) OpenLibs()

OpenLibs loads the built-in libraries. It is equivalent to running OpenLoad, then OpenBase, then iterating over the other OpenXXX functions in any order.

func (*LState) OptBool

func (ls *LState) OptBool(n int, d bool) bool

func (*LState) OptFunction

func (ls *LState) OptFunction(n int, d *LFunction) *LFunction

func (*LState) OptInt

func (ls *LState) OptInt(n int, d int) int

func (*LState) OptInt64

func (ls *LState) OptInt64(n int, d int64) int64

func (*LState) OptNumber

func (ls *LState) OptNumber(n int, d LNumber) LNumber

func (*LState) OptString

func (ls *LState) OptString(n int, d string) string

func (*LState) OptTable

func (ls *LState) OptTable(n int, d *LTable) *LTable

func (*LState) OptUserData

func (ls *LState) OptUserData(n int, d *LUserData) *LUserData

func (*LState) PCall

func (ls *LState) PCall(nargs, nret int, errfunc *LFunction) (err error)

func (*LState) Pop

func (ls *LState) Pop(n int)

func (*LState) PreloadModule

func (ls *LState) PreloadModule(name string, loader LGFunction)

PreloadModule sets a module loader to the package.preload table.

func (*LState) Push

func (ls *LState) Push(value LValue)

func (*LState) RaiseError

func (ls *LState) RaiseError(format string, args ...any)

RaiseError is equivalent to luaL_error( http://www.lua.org/manual/5.1/manual.html#luaL_error ).

func (*LState) RawEqual

func (ls *LState) RawEqual(lhs, rhs LValue) bool

func (*LState) RawGet

func (ls *LState) RawGet(tb *LTable, key LValue) LValue

func (*LState) RawGetInt

func (ls *LState) RawGetInt(tb *LTable, key int) LValue

func (*LState) RawSet

func (ls *LState) RawSet(tb *LTable, key LValue, value LValue)

func (*LState) RawSetInt

func (ls *LState) RawSetInt(tb *LTable, key int, value LValue)

func (*LState) Register

func (ls *LState) Register(name string, fn LGFunction)

func (*LState) RegisterGoModule

func (ls *LState) RegisterGoModule(name string, funcs map[string]LGoFunc) LValue

RegisterGoModule registers a module using LGoFunc functions. LGoFunc values are stored directly without wrapping.

func (*LState) RegisterModule

func (ls *LState) RegisterModule(name string, funcs map[string]LGFunction) LValue

func (*LState) Remove

func (ls *LState) Remove(index int)

func (*LState) RemoveContext

func (ls *LState) RemoveContext() context.Context

RemoveContext removes the context associated with this LState and returns this context.

func (*LState) Replace

func (ls *LState) Replace(idx int, value LValue)

func (*LState) Resume

func (ls *LState) Resume(th *LState, fn *LFunction, args ...LValue) (ResumeState, []LValue, error)

func (*LState) ResumeInto

func (ls *LState) ResumeInto(th *LState, fn *LFunction, retBuf []LValue, args ...LValue) (ResumeState, []LValue, error)

ResumeInto is like Resume but uses a pre-allocated buffer for return values. This avoids allocations in the hot path.

func (*LState) SetContext

func (ls *LState) SetContext(ctx context.Context)

SetContext set a context ctx to this LState. The provided ctx must be non-nil.

func (*LState) SetField

func (ls *LState) SetField(obj LValue, key string, value LValue)

func (*LState) SetFuncs

func (ls *LState) SetFuncs(tb *LTable, funcs map[string]LGFunction, upvalues ...LValue) *LTable

func (*LState) SetGlobal

func (ls *LState) SetGlobal(name string, value LValue)

func (*LState) SetGoFuncs

func (ls *LState) SetGoFuncs(tb *LTable, funcs map[string]LGoFunc) *LTable

SetGoFuncs sets LGoFunc values directly on the table.

func (*LState) SetLocal

func (ls *LState) SetLocal(dbg *Debug, no int, lv LValue) string

func (*LState) SetMetatable

func (ls *LState) SetMetatable(obj LValue, mt LValue)

func (*LState) SetTable

func (ls *LState) SetTable(obj LValue, key LValue, value LValue)

func (*LState) SetTop

func (ls *LState) SetTop(idx int)

func (*LState) SetUpvalue

func (ls *LState) SetUpvalue(fn *LFunction, no int, lv LValue) string

func (*LState) Status

func (ls *LState) Status(th *LState) string

func (*LState) String

func (ls *LState) String() string

func (*LState) ToBool

func (ls *LState) ToBool(n int) bool

func (*LState) ToFunction

func (ls *LState) ToFunction(n int) *LFunction

func (*LState) ToInt

func (ls *LState) ToInt(n int) int

func (*LState) ToInt64

func (ls *LState) ToInt64(n int) int64

func (*LState) ToNumber

func (ls *LState) ToNumber(n int) LNumber

func (*LState) ToString

func (ls *LState) ToString(n int) string

func (*LState) ToStringMeta

func (ls *LState) ToStringMeta(lv LValue) LValue

ToStringMeta returns string representation of given LValue. This method calls the `__tostring` meta method if defined.

func (*LState) ToTable

func (ls *LState) ToTable(n int) *LTable

func (*LState) ToThread

func (ls *LState) ToThread(n int) *LState

func (*LState) ToUserData

func (ls *LState) ToUserData(n int) *LUserData

func (*LState) Type

func (ls *LState) Type() LValueType

func (*LState) TypeError

func (ls *LState) TypeError(n int, typ LValueType)

func (*LState) Where

func (ls *LState) Where(level int) string

func (*LState) XMoveTo

func (ls *LState) XMoveTo(other *LState, n int)

func (*LState) Yield

func (ls *LState) Yield(values ...LValue) int

type LString

type LString string

func (LString) Format

func (st LString) Format(f fmt.State, c rune)

Format implements the fmt.Formatter interface.

func (LString) String

func (st LString) String() string

func (LString) Type

func (st LString) Type() LValueType

type LTable

type LTable struct {
	Metatable LValue
	Immutable bool

	Array   []LValue
	Dict    map[LValue]LValue
	Strdict map[string]LValue
	Keys    []LValue
	K2i     map[LValue]int
}

func CreateTable

func CreateTable(acap, hcap int) *LTable

func (*LTable) Append

func (tb *LTable) Append(value LValue) bool

Append appends a given LValue to this LTable.

func (*LTable) ForEach

func (tb *LTable) ForEach(cb func(LValue, LValue))

ForEach iterates over this table of elements, yielding each in turn to a given function.

func (*LTable) Insert

func (tb *LTable) Insert(i int, value LValue) bool

Insert inserts a given LValue at position `i` in this table.

func (*LTable) Len

func (tb *LTable) Len() int

Len returns length of this LTable without using __len.

func (*LTable) MaxN

func (tb *LTable) MaxN() int

MaxN returns a maximum number key that nil value does not exist before it.

func (*LTable) Next

func (tb *LTable) Next(key LValue) (LValue, LValue)

Next is equivalent to lua_next ( http://www.lua.org/manual/5.1/manual.html#lua_next ).

func (*LTable) RawGet

func (tb *LTable) RawGet(key LValue) LValue

RawGet returns an LValue associated with a given key without __index metamethod.

func (*LTable) RawGetH

func (tb *LTable) RawGetH(key LValue) LValue

RawGetH returns an LValue associated with a given key without __index metamethod.

func (*LTable) RawGetInt

func (tb *LTable) RawGetInt(key int) LValue

RawGetInt returns an LValue at position `key` without __index metamethod.

func (*LTable) RawGetString

func (tb *LTable) RawGetString(key string) LValue

RawGetString returns an LValue associated with a given key without __index metamethod.

func (*LTable) RawSet

func (tb *LTable) RawSet(key LValue, value LValue) bool

RawSet sets a given LValue to a given index without the __newindex metamethod. It is recommended to use `RawSetString` or `RawSetInt` for performance if you already know the given LValue is a string or number.

func (*LTable) RawSetH

func (tb *LTable) RawSetH(key LValue, value LValue) bool

RawSetH sets a given LValue to a given index without the __newindex metamethod. OPTIMIZED: No longer creates Keys/K2i or Dict until actually needed

func (*LTable) RawSetInt

func (tb *LTable) RawSetInt(key int, value LValue) bool

RawSetInt sets a given LValue at a position `key` without the __newindex metamethod.

func (*LTable) RawSetString

func (tb *LTable) RawSetString(key string, value LValue) bool

RawSetString sets a given LValue to a given string index without the __newindex metamethod.

func (*LTable) Remove

func (tb *LTable) Remove(pos int) (LValue, bool)

Remove removes from this table the element at a given position.

func (*LTable) String

func (tb *LTable) String() string

func (*LTable) Type

func (tb *LTable) Type() LValueType

type LType

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

LType is a runtime type value that can be used in Lua code. It wraps a typ.Type and implements the LValue interface. Types are first-class values: callable for validation, comparable, and support reflection via direct VM dispatch (no metatables).

func NewLType

func NewLType(t typ.Type) *LType

NewLType creates a new LType wrapping the given type.

func NewNamedLType

func NewNamedLType(t typ.Type, name string) *LType

NewNamedLType creates a new named LType.

func (*LType) GoString

func (lt *LType) GoString() string

Debug helper

func (*LType) Inner

func (lt *LType) Inner() typ.Type

Inner returns the underlying typ.Type.

func (*LType) KindString

func (lt *LType) KindString() string

KindString returns a string representation of the type's kind.

func (*LType) Name

func (lt *LType) Name() string

Name returns the type name, or empty string for anonymous types.

func (*LType) String

func (lt *LType) String() string

func (*LType) Type

func (lt *LType) Type() LValueType

func (*LType) Validate

func (lt *LType) Validate(L *LState, val LValue) bool

Validate checks if a value matches this type. Returns true if valid, false otherwise.

type LUserData

type LUserData struct {
	Value     interface{}
	Metatable LValue
}

func (*LUserData) String

func (ud *LUserData) String() string

func (*LUserData) Type

func (ud *LUserData) Type() LValueType

type LValue

type LValue interface {
	String() string
	Type() LValueType
}

type LValueType

type LValueType int
const (
	LTNil LValueType = iota
	LTBool
	LTNumber
	LTInteger
	LTString
	LTFunction
	LTUserData
	LTThread
	LTTable
	LTChannel
	LTType
)

func (LValueType) String

func (vt LValueType) String() string

type Options

type Options struct {
	// Call stack size. This defaults to `lua.CallStackSize`.
	CallStackSize int
	// Data stack size. This defaults to `lua.RegistrySize`.
	RegistrySize int
	// Allow the registry to grow from the registry size specified up to a value of RegistryMaxSize. A value of 0
	// indicates no growth is permitted. The registry will not shrink again after any growth.
	RegistryMaxSize int
	// If growth is enabled, step up by an additional `RegistryGrowStep` each time to avoid having to resize too often.
	// This defaults to `lua.RegistryGrowStep`
	RegistryGrowStep int
	// Controls whether or not libraries are opened by default
	SkipOpenLibs bool
	// Tells whether a Go stacktrace should be included in a Lua stacktrace when panics occur.
	IncludeGoStackTrace bool
	// If `MinimizeStackMemory` is set, the call stack will be automatically grown or shrank up to a limit of
	// `CallStackSize` in order to minimize memory usage. This does incur a slight performance penalty.
	MinimizeStackMemory bool
}

Options is a configuration that is used to create a new LState.

type P

type P struct {
	Fn      LValue
	NRet    int
	Protect bool
	Handler *LFunction
}

type ResumeState

type ResumeState int
const (
	ResumeOK ResumeState = iota
	ResumeYield
	ResumeError
)

type SpawnRequest

type SpawnRequest struct {
	Fn *LFunction
}

SpawnRequest is yielded by coroutine.spawn to signal the scheduler

func (*SpawnRequest) String

func (s *SpawnRequest) String() string

func (*SpawnRequest) Type

func (s *SpawnRequest) Type() LValueType

type StackFrame

type StackFrame struct {
	Level       int
	Source      string
	CurrentLine int
	Name        string
	FuncType    string
}

StackFrame represents a single frame in the Lua stack (for error reporting).

func (StackFrame) String

func (sf StackFrame) String() string

type StackTrace

type StackTrace struct {
	ThreadID string
	Frames   []StackFrame
}

StackTrace represents a Lua stack trace.

func (StackTrace) String

func (st StackTrace) String() string

type Ternary

type Ternary int8

Ternary represents three-state logic for composable error handling.

const (
	TernaryUnknown Ternary = 0
	TernaryTrue    Ternary = 1
	TernaryFalse   Ternary = 2
)

func (Ternary) Bool

func (t Ternary) Bool() bool

func (Ternary) String

func (t Ternary) String() string

type Upvalue

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

func (*Upvalue) Close

func (uv *Upvalue) Close()

func (*Upvalue) IsClosed

func (uv *Upvalue) IsClosed() bool

func (*Upvalue) SetValue

func (uv *Upvalue) SetValue(value LValue)

func (*Upvalue) Value

func (uv *Upvalue) Value() LValue

type ValidationContext

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

ValidationContext wraps validate.Registry for LValue validation.

func DefaultValidationContext

func DefaultValidationContext() *ValidationContext

DefaultValidationContext returns context with built-in validators.

func NewValidationContext

func NewValidationContext() *ValidationContext

NewValidationContext creates empty context.

func (*ValidationContext) RegisterValidator

func (vc *ValidationContext) RegisterValidator(name string, fn ValidatorFunc)

RegisterValidator adds a validator that works with LValue.

func (*ValidationContext) Validate

func (vc *ValidationContext) Validate(val LValue, lt *LType) []*validate.Error

Validate checks value against type with annotations. Uses zero-alloc path building - paths only built on error.

type ValidatorFunc

type ValidatorFunc func(val LValue, arg any) *validate.Error

ValidatorFunc validates an LValue against an annotation argument.

Directories

Path Synopsis
compiler
ast
Package ast defines the abstract syntax tree for Lua source code.
Package ast defines the abstract syntax tree for Lua source code.
bind
Package bind implements name resolution and symbol binding for Lua AST nodes.
Package bind implements name resolution and symbol binding for Lua AST nodes.
bytecode
Package bytecode provides serialization and deserialization of compiled Lua bytecode.
Package bytecode provides serialization and deserialization of compiled Lua bytecode.
cfg
Package cfg constructs control flow graphs from Lua AST nodes.
Package cfg constructs control flow graphs from Lua AST nodes.
cfg/analysis
Package analysis provides pure graph analysis algorithms for CFGs.
Package analysis provides pure graph analysis algorithms for CFGs.
cfg/extraction
Package extraction provides pure AST extraction functions for CFG construction.
Package extraction provides pure AST extraction functions for CFG construction.
check
Package check implements a multi-phase, fixpoint-iterative type checking system for Lua.
Package check implements a multi-phase, fixpoint-iterative type checking system for Lua.
check/api
Package api defines interfaces and types for the Lua type checker.
Package api defines interfaces and types for the Lua type checker.
check/effects
Package effectops provides operations for function effect propagation.
Package effectops provides operations for function effect propagation.
check/flowbuild
Package flowbuild implements flow constraint extraction from control flow graphs.
Package flowbuild implements flow constraint extraction from control flow graphs.
check/flowbuild/assign
Package assign provides flow-sensitive assignment analysis for the type checker.
Package assign provides flow-sensitive assignment analysis for the type checker.
check/flowbuild/cond
Package cond implements condition constraint extraction for the flow type system.
Package cond implements condition constraint extraction for the flow type system.
check/flowbuild/constprop
Package constprop performs constant propagation for flow analysis.
Package constprop performs constant propagation for flow analysis.
check/flowbuild/core
Package base provides shared context types for flowbuild operations.
Package base provides shared context types for flowbuild operations.
check/flowbuild/decl
Package decl extracts type declarations from function parameters and locals.
Package decl extracts type declarations from function parameters and locals.
check/flowbuild/guard
Package guard extracts type guard conditions from control flow branches.
Package guard extracts type guard conditions from control flow branches.
check/flowbuild/keyscoll
Package keyscoll collects table keys from expressions for type inference.
Package keyscoll collects table keys from expressions for type inference.
check/flowbuild/literal
Package literal handles literal expression type synthesis for flow analysis.
Package literal handles literal expression type synthesis for flow analysis.
check/flowbuild/mutator
Package mutator extracts container mutation operations from call sites.
Package mutator extracts container mutation operations from call sites.
check/flowbuild/numconst
Package numconst handles numeric constant analysis for type inference.
Package numconst handles numeric constant analysis for type inference.
check/flowbuild/path
Package path constructs constraint paths from AST expressions.
Package path constructs constraint paths from AST expressions.
check/flowbuild/predicate
Package predicate builds type predicates from comparison expressions.
Package predicate builds type predicates from comparison expressions.
check/flowbuild/resolve
Package resolve provides symbol and type resolution utilities for flow constraint extraction.
Package resolve provides symbol and type resolution utilities for flow constraint extraction.
check/flowbuild/returns
Package returns extracts return type information from function bodies.
Package returns extracts return type information from function bodies.
check/flowbuild/sibling
Package sibling handles sibling function analysis in nested scopes.
Package sibling handles sibling function analysis in nested scopes.
check/flowbuild/tblutil
Package tblutil provides utilities for table type analysis.
Package tblutil provides utilities for table type analysis.
check/hooks
assign_check.go implements assignment type validation for the type checker.
assign_check.go implements assignment type validation for the type checker.
check/infer/captured
Package captured computes captured variable types for nested functions.
Package captured computes captured variable types for nested functions.
check/infer/interproc
Package interproc handles interprocedural analysis after flow solving.
Package interproc handles interprocedural analysis after flow solving.
check/infer/nested
Package nestedinfer processes nested function definitions during type analysis.
Package nestedinfer processes nested function definitions during type analysis.
check/infer/paramhints
Package paramhints infers parameter types from call site arguments.
Package paramhints infers parameter types from call site arguments.
check/infer/return
Package infer infers function return types from body analysis.
Package infer infers function return types from body analysis.
check/modules
Package modules handles module export type computation.
Package modules handles module export type computation.
check/nested
Package nested handles nested function analysis coordination.
Package nested handles nested function analysis coordination.
check/phase
Package phase implements individual analysis phases for type checking.
Package phase implements individual analysis phases for type checking.
check/pipeline
This package handles post-analysis diagnostic operations:
This package handles post-analysis diagnostic operations:
check/returns
Package returns provides interprocedural return type analysis.
Package returns provides interprocedural return type analysis.
check/scope
Package scope provides lexical scope state for type checking.
Package scope provides lexical scope state for type checking.
check/siblings
Package siblings manages sibling function type coordination.
Package siblings manages sibling function type coordination.
check/store
Package store provides session state management for type checking.
Package store provides session state management for type checking.
check/synth
Package synth implements type synthesis for Lua expressions.
Package synth implements type synthesis for Lua expressions.
check/synth/intercept
Package intercept handles special-case type synthesis interceptions.
Package intercept handles special-case type synthesis interceptions.
check/synth/ops
Package ops implements type synthesis operations for the type checker.
Package ops implements type synthesis operations for the type checker.
check/synth/phase/core
Package shared provides shared utilities for synthesis phases.
Package shared provides shared utilities for synthesis phases.
check/synth/phase/extract
Package extract handles expression extraction from CFG for synthesis.
Package extract handles expression extraction from CFG for synthesis.
check/synth/phase/resolve
Package resolve performs final type resolution after synthesis.
Package resolve performs final type resolution after synthesis.
check/synth/transform
Package transform provides type transformation operations.
Package transform provides type transformation operations.
parse
Package parse implements lexical analysis and parsing for Lua source code.
Package parse implements lexical analysis and parsing for Lua source code.
stdlib
Package stdlib provides type definitions for Lua's standard library.
Package stdlib provides type definitions for Lua's standard library.
Package internal provides pure data structures for the type system.
Package internal provides pure data structures for the type system.
lsp
Package lsp provides LSP query operations for the type system.
Package lsp provides LSP query operations for the type system.
completion
Package completion provides code completion for LSP.
Package completion provides code completion for LSP.
edit
Package edit provides text editing utilities for the language server.
Package edit provides text editing utilities for the language server.
index
Package index provides per-function indexing for type checking results.
Package index provides per-function indexing for type checking results.
refactor
Package refactor provides code refactoring operations for the language server.
Package refactor provides code refactoring operations for the language server.
semantic
Package semantic provides semantic token analysis for syntax highlighting.
Package semantic provides semantic token analysis for syntax highlighting.
signature
Package signature provides function signature help for the language server.
Package signature provides function signature help for the language server.
Package pm provides Lua pattern matching functions for Go.
Package pm provides Lua pattern matching functions for Go.
types
cfg
Package cfg provides control flow graph representation for dataflow analysis.
Package cfg provides control flow graph representation for dataflow analysis.
constraint
Package constraint provides multi-path narrowing constraints for type refinement.
Package constraint provides multi-path narrowing constraints for type refinement.
constraint/theory
Package theory provides modular constraint solving theories for SMT-style reasoning.
Package theory provides modular constraint solving theories for SMT-style reasoning.
contract
Package contract provides function behavior specifications using Hoare-style contracts.
Package contract provides function behavior specifications using Hoare-style contracts.
db
Package db provides a Salsa-style incremental computation database for efficient re-analysis when source files change.
Package db provides a Salsa-style incremental computation database for efficient re-analysis when source files change.
diag
Package diag provides diagnostic reporting for the type checker.
Package diag provides diagnostic reporting for the type checker.
effect
Effect label codecs for serialization and deserialization.
Effect label codecs for serialization and deserialization.
flow
Package flow provides control flow type propagation and flow-sensitive analysis.
Package flow provides control flow type propagation and flow-sensitive analysis.
flow/domain
Package domain provides abstract domain interfaces for constraint solving.
Package domain provides abstract domain interfaces for constraint solving.
flow/join
Package join provides type joining operations for phi node merging.
Package join provides type joining operations for phi node merging.
flow/numeric
domain.go implements the numeric subdomain for the flow solver's ProductDomain.
domain.go implements the numeric subdomain for the flow solver's ProductDomain.
flow/pathkey
key.go provides path key construction and manipulation utilities.
key.go provides path key construction and manipulation utilities.
flow/propagate
Package propagate computes type constraints at CFG points via forward propagation.
Package propagate computes type constraints at CFG points via forward propagation.
io
Package io provides binary serialization and deserialization for Lua types.
Package io provides binary serialization and deserialization for Lua types.
kind
Package kind defines type kind enumeration for efficient type discrimination.
Package kind defines type kind enumeration for efficient type discrimination.
narrow
Package narrow provides type narrowing operations for control flow refinement.
Package narrow provides type narrowing operations for control flow refinement.
query/core
Package core provides pure type inspection, query, and lookup operations for the Lua type system.
Package core provides pure type inspection, query, and lookup operations for the Lua type system.
subtype
Package subtype provides subtype checking with seen-map cycle detection.
Package subtype provides subtype checking with seen-map cycle detection.
typ
Package typ defines the core Type interface and type implementations.
Package typ defines the core Type interface and type implementations.
typ/join
Package join provides type join operations for control flow merging.
Package join provides type join operations for control flow merging.
typ/subst
Package subst provides type substitution operations for generics.
Package subst provides type substitution operations for generics.
typ/union
Package union provides union type analysis operations.
Package union provides union type analysis operations.
typ/unwrap
Package unwrap provides type unwrapping, extraction, and predicate operations.
Package unwrap provides type unwrapping, extraction, and predicate operations.
Package validate provides validation for LValue types.
Package validate provides validation for LValue types.

Jump to

Keyboard shortcuts

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