Skip to content

zig fmt of array init with switch not idempotent #22778

@ifreund

Description

@ifreund

Zig Version

0.14.0-dev.3051+cf059ee08

Steps to Reproduce and Observed Behavior

Initial code:

const bar = .{ .{ switch ({}) {
        else => {},
    } }, .{}, .{}, .{},
};

After a single zig fmt invocation:

const bar = .{
    .{switch ({}) {
        else => {},
    }},
    .{}, .{},
    .{},
};

After two or more zig fmt invocations:

const bar = .{
    .{switch ({}) {
        else => {},
    }},
    .{},
    .{},
    .{},
};

Expected Behavior

It should only take a single zig fmt invocation to reach the canonical format.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorcontributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.zig fmt

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions