Ruta graveolens  ·  notes from a language experiment  ·  cultivated since 2025

E0412: Undefined assoc fn

CodeCategoryStability
E0412Struct and enumPermanent

Explanation

An associated-style call names no callable member on the selected type. For a struct, the missing member would be an associated function declared without self; this code also covers a missing called variant on an inline comptime-produced enum type.

Likely cause

The member or type name is wrong, a struct method requiring a receiver value was intended, or an inline comptime-produced enum has no variant with the called name. Check the selected type's declarations and use the call form that matches the intended member.

Examples

Unknown associated function

struct Point { x: i32 }
fn main() -> i32 {
    Point.origin().x
}

Declare and call an associated function

struct Point {
    x: i32,

    fn origin() -> Point { Point { x: 0 } }
}
fn main() -> i32 {
    Point.origin().x
}

References