Skip to content

zig: tagged-union variants are dropped from the graph #4049

Closed

Description

@rajatnagda45

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.

Activity

  1. github-actions commented on Oct 4, 2026

    @github-actions

    Thanks for opening this issue, @rajatnagda45. A maintainer will take a look soon.

    If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.

    To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.

  2. safishamsi commented on Oct 4, 2026

    @safishamsi
    Member

    Fixed in v0.9.76 (live on PyPI as graphifyy==0.9.76) via #4050, thanks @rajatnagda45. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions