Skip to main content

Module warnings

Module warnings 

Source
Expand description

The Godot warning catalog + the emit-then-gate seam (Phase-6 Workstream 1).

Severity is a resolved property, not a baked-in one. Inference records a RawWarning (a code + range + message, no severity); the pure gate function resolves it against the project’s WarningSettings and the per-file SuppressionMap into a final Diagnostic (or drops it). Because gate runs downstream of the cached analyze_file query (in gdscript-ide’s type_diagnostics), editing a warning level never invalidates inference — the salsa-cacheability invariant (Playbook §6).

WarningCode is the single source of truth for the gateable Godot codes. The public Diagnostic.code stays a stable String (via WarningCode::as_str) so the wire contract is unchanged — the enum is internal to gdscript-hir.

Structs§

RawWarning
An emitted-but-ungraded warning: the inference layer records these (no severity); gate resolves each into a final Diagnostic or drops it.
SuppressionMap
The @warning_ignore[_start|_restore] suppression spans for one file. A warning is suppressed when its range falls inside a span listing its code. (M0 ships the empty map; the CST walk that populates it lands in W1 M2.)
WarningSettings
The resolved warning configuration for a project (or the standalone analyzer default). Parsed from project.godot’s debug/gdscript/warnings/*; passed to gate.

Enums§

Since
The lowest Godot minor a code exists in. Master means “newer than any stable we bundle as the default model” — gated against the project’s declared engine version.
WarnLevel
Godot’s WarnLevel (gdscript_warning.h): the resolved severity of a code.
WarningCode
A gateable Godot GDScript warning code (research/04 §2.2). Internal to gdscript-hir; the public Diagnostic.code carries its as_str form, so the serialized identity stays a stable string. Adding a variant is a compile error until every table below (as_str, default_level, and ALL) covers it.

Functions§

build_suppression_map
Build the per-file suppression map from the parsed CST (Workstream 1 M2): each @warning_ignore("code", …) suppresses the listed codes over the single following statement/declaration, and a @warning_ignore_start("code")@warning_ignore_restore("code") pair suppresses a region (EOF-terminated if unrestored). Unknown code names are skipped (the unknown-name meta-diagnostic is deferred — see TECH_DEBT.md).
bundled_version
The bundled engine (major, minor) — the default project version and the Since::Master threshold. Parsed from gdscript_api::godot_version (so it tracks the bundled model, not a hardcoded literal).
gate
Resolve one RawWarning into a final Diagnostic, or drop it. The only place settings/version/suppression touch a warning — pure, so it is trivially cacheable and testable. Precedence (research/04 §2.3): enable → per-code level → treat-as-errors → scope → suppression.
render_warning_reference
Render the Markdown Warning Reference page from the WarningCode catalog (Workstream 5 docgen). The single source of truth — a test asserts the committed page matches this output, so the docs can never drift from the code (regenerate with GDSCRIPT_UPDATE_DOCS=1).