Documentation
¶
Overview ¶
Package typecheck is the shared, side-effect-free type checker for numscript. It synthesizes the (base) type of every expression, resolves variable types from their declarations, and reports type/name/arity errors — fault-tolerantly (it collects all errors instead of bailing, using TypeAny to avoid cascades).
It is the compiler's checker. The analysis module (LSP/CI) keeps its own unification-based checker: asset-identity inference, feature-version gating and lint-style warnings all stay there, and it does not consume this package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DuplicateVariable ¶
type DuplicateVariable struct{ Name string }
func (DuplicateVariable) Message ¶
func (e DuplicateVariable) Message() string
func (DuplicateVariable) Severity ¶
func (DuplicateVariable) Severity() Severity
type ErrorKind ¶
type ErrorKind interface {
Message() string
Severity() Severity
// contains filtered or unexported methods
}
ErrorKind is both a typecheck error and a renderable diagnostic (Message + Severity), so callers can push it as a diagnostic without a translation layer.
type InvalidType ¶
type InvalidType struct{ Name string }
func (InvalidType) Message ¶
func (e InvalidType) Message() string
func (InvalidType) Severity ¶
func (InvalidType) Severity() Severity
type Severity ¶
type Severity = byte
Severity mirrors the LSP DiagnosticSeverity spec (and analysis.Severity, an alias of byte too) so an ErrorKind directly satisfies analysis.DiagnosticKind.
type Type ¶
type Type = string
const ( TypeNumber Type = "number" TypeString Type = "string" TypeAsset Type = "asset" TypeMonetary Type = "monetary" TypeAccount Type = "account" TypePortion Type = "portion" // TypeAny is the type of an expression whose type couldn't be determined // (e.g. an unbound variable or an unknown function). It's compatible with // everything, so it suppresses cascading errors. TypeAny Type = "any" )
type TypeMismatch ¶
type TypeMismatch struct{ Expected, Got string }
func (TypeMismatch) Message ¶
func (e TypeMismatch) Message() string
func (TypeMismatch) Severity ¶
func (TypeMismatch) Severity() Severity
type UnboundVariable ¶
type UnboundVariable struct{ Name, Type string }
func (UnboundVariable) Message ¶
func (e UnboundVariable) Message() string
func (UnboundVariable) Severity ¶
func (UnboundVariable) Severity() Severity
type UnknownFunction ¶
type UnknownFunction struct{ Name, WrongContext string }
UnknownFunction is either a truly-unknown name (WrongContext == "") or a known builtin used in the wrong context (WrongContext is the context it belongs to, e.g. "statement"). typecheck only ever emits the former.
func (UnknownFunction) Message ¶
func (e UnknownFunction) Message() string
func (UnknownFunction) Severity ¶
func (UnknownFunction) Severity() Severity