What happens
A Zig tagged union keeps its methods but loses every variant. Given:
const Shape = union(enum) {
circle: f64,
rectangle: struct { w: f64, h: f64 },
point,
pub fn area(self: Shape) f64 { return 0; }
};
the graph has Shape and .area() but no circle / rectangle / point, so the union sits as a near-memberless leaf.
Why
The container_field branch in graphify/extractors/zig.py only fires when the field's parent is an enum_declaration. A tagged union's variants are container_field nodes under a union_declaration, so they fall through and are never emitted.
Expected
A tagged union's variants are its discriminant cases — the same shape as enum members — so each should become a node with a case_of edge to the union, matching enums (Java #1719, Swift, Scala) and the Zig enum / error-set handling already in place. A bare union { ... } has typed data fields (not cases) and should stay untouched, like a struct's fields.
What happens
A Zig tagged union keeps its methods but loses every variant. Given:
the graph has
Shapeand.area()but nocircle/rectangle/point, so the union sits as a near-memberless leaf.Why
The
container_fieldbranch ingraphify/extractors/zig.pyonly fires when the field's parent is anenum_declaration. A tagged union's variants arecontainer_fieldnodes under aunion_declaration, so they fall through and are never emitted.Expected
A tagged union's variants are its discriminant cases — the same shape as enum members — so each should become a node with a
case_ofedge to the union, matching enums (Java #1719, Swift, Scala) and the Zig enum / error-set handling already in place. A bareunion { ... }has typed data fields (not cases) and should stay untouched, like a struct's fields.