Skip to content

@cImport "union depends on itself" regression #17287

@ypsvlq

Description

@ypsvlq

Zig Version

0.12.0-dev.601+f4c884617

Steps to Reproduce and Observed Behavior

// zig build-exe -target x86_64-windows -lc

const c = @cImport(@cInclude("audioclient.h"));

pub fn main() !void {
    var x: c.TYPEDESC = undefined;
    _ = x;
}
cimport.zig:43579:34: error: union '...cimport.union_unnamed_290' depends on itself
const union_unnamed_290 = extern union {
                          ~~~~~~~^~~~~
cimport.zig:43585:5: note: while checking this field
    unnamed_0: union_unnamed_290 = @import("std").mem.zeroes(union_unnamed_290),
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~```

mingw header:

typedef struct tagTYPEDESC {
    __C89_NAMELESS union {
        struct tagTYPEDESC *lptdesc;
        struct tagARRAYDESC *lpadesc;
        HREFTYPE hreftype;
    } __C89_NAMELESSUNIONNAME;
    VARTYPE vt;
} TYPEDESC;

cimport.zig:

const union_unnamed_290 = extern union {
    lptdesc: [*c]struct_tagTYPEDESC,
    lpadesc: [*c]struct_tagARRAYDESC,
    hreftype: HREFTYPE,
};
pub const struct_tagTYPEDESC = extern struct {
    unnamed_0: union_unnamed_290 = @import("std").mem.zeroes(union_unnamed_290),
    vt: VARTYPE = @import("std").mem.zeroes(VARTYPE),
};
pub const TYPEDESC = struct_tagTYPEDESC;

Expected Behavior

Compiles successfully in 0.11.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorregressionIt worked in a previous version of Zig, but stopped working.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions