Skip to content

Segmentation fault compiling Zig struct with multiple fields with default values #14683

@amp-59

Description

@amp-59

Zig Version

0.11.0-dev.1650+5e7b09ce9

Steps to Reproduce and Observed Behavior

Compile test program with zig build-lib infer_multi_field_default.zig
infer_multi_field_default.zig:

const Full = struct {
    x: bool = default.x,
    y: bool = default.y,
    z: bool = default.z,
};
const default: Full = .{
    .x = true,
    .y = true,
    .z = true,
};
comptime {
    var f: Full = .{};
    _ = f;
}

Compilation will succeed if any field is removed or if the struct is declared extern.

Expected Behavior

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions