Documentation
¶
Overview ¶
Package transform provides type transformation operations.
This package implements type transformations applied during synthesis, including spec-based return type computation and type matching.
Spec Return Transformation ¶
For functions with type specs (generics, overloads):
---@generic T ---@param arr T[] ---@return T function first(arr) ... end
The package computes the concrete return type by:
- Matching argument types to parameter specs
- Binding type variables
- Substituting in the return type spec
Spec Matching ¶
The specmatch subpackage handles pattern matching against type specs, extracting type variable bindings from argument types.
Integration ¶
Transformations are applied during call synthesis to compute concrete return types from generic function specs.
Package transform provides return type transforms owned by the compiler layer. This package applies spec and effect transforms to synthesized return types.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyEffectTransform ¶
func ApplyEffectTransform(fn *typ.Function, args []typ.Type, returnIdx int, baseReturn typ.Type) typ.Type
ApplyEffectTransform applies return type effects to compute the actual return type. If the function has a contract.Spec with a Return effect, the transform is applied to derive the concrete return type from the argument types.
func ApplySpecReturnCases ¶
ApplySpecReturnCases evaluates contract.ReturnSpec cases against argument types. This is pure type-based matching that works when argument types are resolved to literal types. The compiler uses this as a fallback when AST-pattern matching (for inline table constructors) doesn't produce a result.
Ownership: This function provides the pure type-based logic. The compiler owns the decision of when to apply spec returns and coordinates between AST-pattern matching and type-based matching.
Types ¶
This section is empty.