Expand description
Polymorphic pseudo-types — Fase 3 extension.
PG-style anyelement / anyarray / anynonarray /
anycompatible family. These don’t exist as concrete
DataType variants because the analyzer instantiates them
fresh at every call site — a function with signature
array_append(anyarray, anyelement) → anyarray becomes a
distinct concrete signature array_append(int[], int) → int[]
when called with int / int[] arguments.
This module owns:
- The
PseudoTypeenum that the function catalog uses in itsarg_typesslice when declaring polymorphic entries. - The
PolymorphicResolverthat instantiates pseudo-types against concrete call-site arguments, enforcing the consistency rule: everyanyelementat the same signature must resolve to the same concrete type.
Scope today (Fase 3 W3):
AnyElement— matches any single concrete type.AnyArray— matches any array type. Inferred from theAnyElementit shares a signature with.AnyNonArray— matches any concrete type except arrays.AnyCompatible— likeAnyElementbut tolerates implicit widening (e.g.int + float → float).
Deferred:
AnyRange/AnyMultirange— ranges aren’t in Fase 3.AnyEnum— enums are fine via concrete DataType::Enum today; polymorphic enum wait.
This module is not yet wired into the function catalog
or expr_typing. Wiring adds a PseudoType-aware overload in
function_catalog::resolve when the catalog starts shipping
polymorphic rows.
Structs§
- Substitution
- The resolver’s output — a substitution map that every
pseudo-type in a signature has been bound to. Used by
expr_typingto compute the concrete return type from a signature that mentions the same pseudo-type in its return position.
Enums§
- ArgSlot
- A single position in a function argument list — either a concrete type or a pseudo-type waiting for substitution.
- Pseudo
Type - PG-style pseudo-type used by polymorphic function signatures.
The resolver substitutes each variant with a concrete
DataTypeat analyze time based on call-site arguments. - Resolve
Error - Errors raised during polymorphic resolution.
Functions§
- resolve
- Attempt to resolve a polymorphic signature against a list of
concrete call-site argument types. Returns the substitution
on success so
expr_typingcan apply it to the return type.