Expand description
Gradual type inference (Playbook §3.3–§3.6 + §5): a single forward, bottom-up,
bidirectional walk over a lowered Body. No unification variables — types flow forward
from annotations, literals, and the engine API (rust-analyzer’s structure, Pyright’s
gradual semantics).
The walk memoizes every expression’s Ty in InferenceResult::expr_ty (the source of
hover + inlay), does flow-scoped is/as narrowing over the lexical guarded sub-tree, and
raises the §5 type diagnostics. The load-bearing invariant: a Variant/Unknown/Error
receiver is uninformative — it never fires UNSAFE_*, never cascades — so cross-file code
(which lands on Unknown via the seam) produces zero false diagnostics.
Structs§
- Binding
- A typed local binding — the unit hover + inlay hints read for
var/param/fornames. - File
Inference - The full single-file inference: the item tree, every inferred unit, and the merged §5 diagnostics. The whole-file entry point the IDE layer consumes.
- Inference
Result - The result of inferring one body.
- Unit
- One inferred unit of a file: a function body or a class field’s initializer, with its
lowered
BodyandInferenceResult(kept so position-based features — hover, inlay, member completion — can map a cursor back through the source map).
Enums§
- Binding
Kind - What kind of binding a
Bindingdescribes.
Constants§
- CYCLIC_
INHERITANCE - A genuine
extendscycle: a file’s base chain transitively returns to itself (A extends B,B extends A). Illegal in Godot (gdscript_analyzer.cppraises it). Only theextendsinheritance chain cycles — apreload/loadcycle is legal at runtime and is NOT reported. - INFERENCE_
ON_ VARIANT :=/ inferred binding from a statically-Variantvalue.- INTEGER_
DIVISION int / int.- INVALID_
NODE_ PATH - A
$Path/%Unique/get_node("…")whose literal path is genuinely absent in the owning scene (only raised when the script attaches to exactly one scene — never on an../absolute path or a path that descends into an instanced sub-scene we don’t see). - NARROWING_
CONVERSION floatstored into anintslot.- SHADOWED_
GLOBAL_ IDENTIFIER - A declared
class_namethat shadows another global identifier — a duplicate userclass_name, an engine/native class, a builtin/utility, a global enum/const, or a*-autoload singleton. Godot’sgdscript_analyzer.cppraises this (as an error) so the global namespace stays unique. - TYPE_
MISMATCH - Incompatible hard types (our umbrella for the engine’s
push_error). - UNSAFE_
CALL_ ARGUMENT - An argument whose static type needs an unsafe implicit cast (
Variant/ a downcast) into the resolved parameter type — Godot’s per-argument value-prop warning. - UNSAFE_
METHOD_ ACCESS - A method missing on a statically-known base.
- UNSAFE_
PROPERTY_ ACCESS - A property missing on a statically-known base.
Functions§
- analyze_
file - Infer an entire file: lower its item tree, then infer every function body and every
class-field initializer against a shared
ClassScope. The single entry point for the IDE features (Playbook §6 — a pure(api, parsed file) -> resultfunction). - infer
- Infer a lowered
body(itstailinitializer expression and/or its statement block).return_tyis the function’s declared return type (Variantif none / for an initializer body). - infer_
func - Convenience: recover a function node from its
AstPtr, lower its body, resolve its declared return type, and infer it.