Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zig fmt of array init with switch not idempotent #22778

Open
ifreund opened this issue Feb 5, 2025 · 0 comments · May be fixed by #23250
Open

zig fmt of array init with switch not idempotent #22778

ifreund opened this issue Feb 5, 2025 · 0 comments · May be fixed by #23250
Labels
bug Observed behavior contradicts documented or intended behavior contributor friendly This issue is limited in scope and/or knowledge of Zig internals. zig fmt
Milestone

Comments

@ifreund
Copy link
Member

ifreund commented Feb 5, 2025

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.

@ifreund ifreund added bug Observed behavior contradicts documented or intended behavior contributor friendly This issue is limited in scope and/or knowledge of Zig internals. zig fmt labels Feb 5, 2025
@ifreund ifreund added this to the 0.15.0 milestone Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior contributor friendly This issue is limited in scope and/or knowledge of Zig internals. zig fmt
Projects
None yet
1 participant