slang-interface-conformance-missing-method
Status: shipped (Phase 8.C — ADR 0021 sub-phase C, v1.5.0).
What it detects
An extension Foo : IFoo {} block whose body fails to implement every method declared on the conformed-to interface. The rule walks the tree-sitter-slang AST in two passes:
- Collect every
interface_specifierdeclared in the translation unit into an(interface-name -> set-of-method-names)map. A "method" is anyfield_declarationinside the interface'sfield_declaration_listbody whosedeclaratorfield is afunction_declarator. - Walk every
extension_specifiernode carrying abase_class_clausechild (the: IFooconformance form) and intersect the methods defined inside the extension'sfield_declaration_listbody against the interface's required-method set. Every missing method fires an Error-severity diagnostic.
The rule is purely syntactic — no Slang reflection — so it runs without --reflect. Interfaces declared in another module / import-ed translation unit are skipped silently to avoid false positives. Note on actual node-kinds: the prompt's predicted interface_declaration / extension_declaration are NOT what tree-sitter-slang emits; the grammar uses interface_specifier / extension_specifier (documented in the rule body).
Why it matters on a GPU
The cost here is correctness, not performance. Slang's diagnostic for missing-method-conformance is silent at definition site — extension Foo : IFoo {} with an empty body type-checks cleanly until a downstream caller invokes one of the missing methods through a generic that constrains its parameter to IFoo. By that point, the diagnostic points at the call site rather than the broken extension definition, and the developer has to mentally walk back through the inheritance chain to find the actual cause.
Catching the breakage at definition time means the developer fixes the right line of code on the first iteration. The cost on the GPU itself is downstream — an extension that can't satisfy its interface contract either crashes the Slang front-end at use-site (best case) or silently binds to a different overload than the developer expected (worst case, behavioural regression).
Examples
Bad
interface IFoo {
float compute(float x);
float reduce(float a, float b);
}
struct BadImpl { }
// Two diagnostics fire here: one per missing method.
extension BadImpl : IFoo {
}Good
interface IFoo {
float compute(float x);
float reduce(float a, float b);
}
struct GoodImpl { }
extension GoodImpl : IFoo {
float compute(float x) { return x; }
float reduce(float a, float b) { return a + b; }
}Options
none
Fix availability
none — synthesising a method body requires developer intent (behaviour of compute() is not derivable from the interface signature alone). The diagnostic points at the extension and names the missing methods.
See also
- Companion blog post: link to the relevant per-category overview under
../blog/slang-language-overview.mdif one exists; otherwise leave as not yet published until a per-rule post lands.