Skip to content

nested packed structs cause an infinite loop during semantic analysis #25309

@jcollie

Description

@jcollie

Zig Version

0.15.1, 0.14.1, 0.13.0

Steps to Reproduce and Observed Behavior

Given test.zig:

const S = packed struct(u32) {
    b: packed struct(u8) {
        b1: u1 = 0,
        b2: u7 = 0,
    },
    a: u24 = 0,
};

test "packed struct" {
    const x: S = .{ .b = .{ .b1 = 1 } };
    _ = x;
}

zig test test.zig appears to get stuck in an infinite loop during semantic analysis. This happens on 0.15.1, 0.14.1 and 0.13.0.

Expected Behavior

Code should compile or cause an error in a finite amount of time.

Thanks to chocapix on Discord for help minimizing the reproduction.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions