Help us shape the future of Go! Take the 2026 Go Developer Survey

compiler

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CannotCastToString

type CannotCastToString struct {
	parser.Range
	Type typecheck.Type
}

CannotCastToString is reported for an interpolation part whose type has no string form (monetary, asset, portion).

func (CannotCastToString) Error

func (e CannotCastToString) Error() string

type CannotStoreScopedAccountInMeta

type CannotStoreScopedAccountInMeta struct {
	parser.Range
}

CannotStoreScopedAccountInMeta is reported when a scoped account (the result of scoped()) is used as the *value* stored by set_tx_meta or set_account_meta. Mirrors the interpreter's runtime error of the same name, but caught at compile time since the compiler already knows an expression's scopedness statically.

func (CannotStoreScopedAccountInMeta) Error

type CompilerError

type CompilerError interface {
	error
	parser.Ranged
	// contains filtered or unexported methods
}

type DuplicateRemaining

type DuplicateRemaining struct {
	parser.Range
}

func (DuplicateRemaining) Error

func (DuplicateRemaining) Error() string

type ExperimentalFeature

type ExperimentalFeature struct {
	parser.Range
	FlagName flags.FeatureFlag
}

ExperimentalFeature is reported when the script uses a construct gated behind a feature flag that wasn't enabled. Mirrors the interpreter's interpreter.ExperimentalFeature.

func (ExperimentalFeature) Error

func (e ExperimentalFeature) Error() string

type FeatureNotImplemented

type FeatureNotImplemented struct {
	parser.Range
	Feature string
}

FeatureNotImplemented is returned (never panicked) when the compiler meets a construct it does not support yet — e.g. colors or scoped accounts — so the host gets an error instead of a crash.

func (FeatureNotImplemented) Error

func (e FeatureNotImplemented) Error() string

type InvalidFeature

type InvalidFeature struct {
	parser.Range
	Feature string
}

InvalidFeature is reported when a #![feature(..)] declaration names a flag that doesn't exist.

func (InvalidFeature) Error

func (e InvalidFeature) Error() string

type InvalidMetaPosition

type InvalidMetaPosition struct {
	parser.Range
}

InvalidMetaPosition is reported when meta() appears anywhere other than as a top-level variable origin (the only place it's supported).

func (InvalidMetaPosition) Error

func (InvalidMetaPosition) Error() string

type InvalidScopedAccountPosition

type InvalidScopedAccountPosition struct {
	parser.Range
}

InvalidScopedAccountPosition is reported when scoped() is reached from a position that only wants a plain string/generic value (e.g. account interpolation, or any other non-account context) — a defensive check that should be unreachable given the compiler's other call sites already route account-typed expressions through compileAccountExpr.

func (InvalidScopedAccountPosition) Error

type InvalidUncappedSource

type InvalidUncappedSource struct {
	parser.Range
}

func (InvalidUncappedSource) Error

func (InvalidUncappedSource) Error() string

type InvalidVariableValue added in v0.1.2

type InvalidVariableValue struct {
	Name  string
	Type  typecheck.Type
	Raw   string
	Cause error
}

InvalidVariableValue is returned by Encode when a variable's raw value does not parse as its declared type.

func (InvalidVariableValue) Error added in v0.1.2

func (e InvalidVariableValue) Error() string

func (InvalidVariableValue) Unwrap added in v0.1.2

func (e InvalidVariableValue) Unwrap() error

type MissingVariable added in v0.1.2

type MissingVariable struct {
	Name string
}

MissingVariable is returned by Encode when the payload has no value for a declared variable.

func (MissingVariable) Error added in v0.1.2

func (e MissingVariable) Error() string

type TypeError

type TypeError struct {
	parser.Range
	Kind typecheck.ErrorKind
}

func (TypeError) Error

func (e TypeError) Error() string

type UnboundVar

type UnboundVar struct {
	parser.Range
	Var string
}

func (UnboundVar) Error

func (e UnboundVar) Error() string

type UnsupportedNode

type UnsupportedNode struct {
	parser.Range
	Node any
}

UnsupportedNode is the compiler's defensive backstop for a switch over an AST node, operator, or builtin name that's meant to be exhaustive (every case the parser/typecheck can currently produce is handled) but isn't enforced as such by the Go compiler — e.g. a switch on a string-typed operator, or a fixed set of builtin names. Reaching it means the compiler has drifted out of sync with the parser or typecheck, not something a script can trigger, so the message carries a debug dump rather than user-actionable text.

func (UnsupportedNode) Error

func (e UnsupportedNode) Error() string

type VarsEncoder

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

func Compile

func Compile(program parser.Program, featureFlags map[string]struct{}) (VarsEncoder, vm.Program, error)

Compile lowers a parsed program to the VarsEncoder that turns a json var payload into the vm.Vars the program expects, plus the vm.Program itself.

featureFlags is the set of experimental features the host allows; a construct gated behind a flag that isn't in the set fails compilation. As in interpreter.RunProgram, the script's own #![feature(..)] declarations are unioned in.

func (VarsEncoder) Encode

func (e VarsEncoder) Encode(vars map[string]string) (vm.Vars, error)

TODO review AI blob

Jump to

Keyboard shortcuts

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