Inference
Last updated
Last updated
Lexica is a staticly typed language and relies on type inference to determine the types of unannotated expressions. Type inference is performed using unification constraint solving and immediately solved at the site of the constraint.
A type context for the function that was requested. May raise inference errors.
Requires the function node of the requested function.
Templates in a function are represented with a template inference type.
Templates cannot unify with an instance. Templates can only be unified with themselves or inference variables. This prevents erroneous unification of templates with other templates.
When a template function is used, templates are replaced with fresh inference variables and are unified as normal.
The type of a field or method call cannot be determined until the expression type itself is known.
Hence, unification of fields and method calls are deferred until all other expressions have been unified. If the type of the expression is still not resolved an inference error is raised.
Structure
Description
Inference Type
Represents a type variable or solved type
Engine
Stores and unifies type variables based on constraints
Environment
Maps expressions and variables to type variables and inference types
Type Resolution
Represents a resolved type
Type Context
Maps expressions and variables to resolved types