Skip to content

False dependency loop #14147

@DerryAlex

Description

@DerryAlex

Zig Version

0.11.0-dev.923+a52dcdd3c

Steps to Reproduce and Observed Behavior

Possibly related #14005

Observed Behavior:

error: struct 'GLib.SListNullable' depends on itself
pub const SListNullable = packed struct {
                          ~~~~~~~^~~~~~
referenced by:
    SListImpl: /home/chief/workplace/gir-zig/generate/output/GLib.zig:8243:30
    SListNullable: /home/chief/workplace/gir-zig/generate/output/GLib.zig:8250:17
    SListNullable: /home/chief/workplace/gir-zig/generate/output/GLib.zig:8249:34
    SListImpl: /home/chief/workplace/gir-zig/generate/output/GLib.zig:8247:15

Related code

pub const SListImpl = extern struct { // L8243
    /// read write 
    Data: ?*anyopaque,
    /// read write 
    Next: core.SListNullable, // L8247
};
pub const SListNullable = packed struct { // L8249
    instance: ?*SListImpl, // L8250

    pub fn new(self: ?SList) SListNullable {
        return .{ .instance = if (self) |some| some.instance else null };
    }

    pub fn get(self: SListNullable) ?SList {
        return if (self.instance) |some| SList{ .instance = some } else null;
    }
};

I failed to narrow down this. If extracted into small files, it behaves correctly. Maybe there is something to do with the file size.

Possibly related infomation

// GLib.zig
const core = @import("core.zig");

// core.zig
const GLib = @import("GLib.zig");
pub usingnamespace GLib;

Expected Behavior

No error

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions