Skip to content

zig fmt leaves @"_" alone in enums, but not in tagged unions #16714

Open
@mk12

Description

@mk12

Zig Version

0.12.0-dev.5+fc6e57568

Steps to Reproduce and Observed Behavior

$ echo 'const A = enum { @"_", _ }; const B = union(enum) { @"_", _ };' > test.zig
$ zig fmt test.zig
test.zig
$ cat test.zig
const A = enum { @"_", _ };
const B = union(enum) { _, _ };

Expected Behavior

I expected zig fmt to treat @"_" in enum and union(enum) the same:

const A = enum { @"_", _ };
const B = union(enum) { @"_", _ };

The behavior was changed for enums in #15617 (cc @jacobly0).

(Although this seems like an obscure corner case, it actually matters for my project. I'm writing a Markdown parser, and enjoy naming my token variants like .@"* * *" instead of e.g. .thematic_break, since that's a needless extra mapping you have to keep in your head. So I want to use .@"_", not .emphasis.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    frontendTokenization, parsing, AstGen, Sema, and Liveness.proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.zig fmt

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions