Skip to main content

generic_record_is_recursive

Function generic_record_is_recursive 

Source
pub fn generic_record_is_recursive(
    name: &str,
    types: &HashMap<String, Arc<TypeDecl>>,
) -> bool
Expand description

v0.174 (#592): does the generic record type name transitively contain a reference to itself — through any field-type path, including collection and Option wrappers, sum-variant payloads, and generic type arguments? Such a type has no finite set of monomorphised boundary codecs: uniform recursion (Node[T] = { next: Option[Node[T]] }) would need a self-referential codec chain the per-instantiation model does not yet generate, and polymorphic recursion (Weird[T] = { next: Option[Weird[List[T]]] }) an unbounded set of instantiations. Both are rejected at a boundary (bynk.generics.recursive_generic_at_boundary).

Detection is reachability over the type-containment graph: name is recursive iff it is reachable from its own body, following every named / applied head and descending into every wrapper, map/result pair, function position, and generic argument. Terminates via the visited set.