Skip to main content

Module ty

Module ty 

Source
Expand description

The Phase-2 type model (Playbook §2/§3.5): the gradual Ty lattice over Variant, the hard/soft TypeSource, the ported is_assignable compatibility check, and TyRefTy resolution against the engine API.

GDScript is gradually typed over one runtime value type, Variant. Three top-ish types are kept distinct on purpose: Ty::Variant (the absorbing gradual top), Ty::Unknown (the Phase-3 cross-file seam — never warns, never cascades, elided from hover), and Ty::Error (already diagnosed — suppresses further cascade).

Structs§

EnumRef
A reference to an enum type, kept as the qualified name it was written with. Phase 2 does not resolve it to a concrete enum table — is_assignable only needs the kind (enum values are assignable to int), and hover shows the qualified name.
ScriptRefId
An opaque reference to another .gd script (by class_name/path). Resolved to a concrete type only in Phase 3; in Phase 2 it never appears (the seam returns Ty::Unknown instead), but the variant exists so the upgrade is additive.
SignalSigId
An interned signal signature id (Phase 3+).
TypedBinding
A typed binding: its Ty plus how the type was established.

Enums§

Assign
The outcome of is_assignable — richer than a bool so the caller can raise the right diagnostic (Playbook §3.5/§5).
Ty
A Phase-2 type. Clone not Copy (the Boxes in Array/Dict).
TypeSource
How a binding’s type was established (Playbook §2). The ordering is load-bearing: a type is hard (statically enforced) iff its source is greater than TypeSource::Inferred.

Functions§

is_assignable
Whether a value of type from may be assigned to a slot of type to (the engine’s check_type_compatibility, ported — Playbook §3.5). Order matters.
resolve_elemref
Resolve a typed-container element ElemRef to a Ty.
resolve_tyref
Resolve an engine-API TyRef (the unresolved form stored in the model) to a Ty.