Skip to content

std.zon.parse: add parsing of enum literals as string - #23261

Open
dasimmet wants to merge 1 commit into
ziglang:masterfrom
dasimmet:mr/enum-literal-as-string
Open

dasimmet wants to merge 1 commit into
ziglang:masterfrom
dasimmet:mr/enum-literal-as-string

Conversation

@dasimmet

Copy link
Copy Markdown
Contributor

Hi @MasonRemaley ,

great job at std.zon!
to fully parse the new build.zig.zon schema's name field at runtime, we do not know the complete enum types,
so instead we could enable parsing those fields into slices.
For Example this type:

struct {
        name: []const u8,
}

can represent this ZON:

.{ .name = .packagen_name }

@dasimmet
dasimmet force-pushed the mr/enum-literal-as-string branch from 62c1be0 to 2b54435 Compare March 15, 2025 20:22

@MasonRemaley MasonRemaley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea.

My only suggested change is to rename enum_literals_as_string -> enum_literals_as_strings, other than that LGTM!

Comment thread lib/std/zon/parse.zig Outdated
Comment thread lib/std/zon/parse.zig Outdated
Comment thread lib/std/zon/parse.zig Outdated
Comment thread lib/std/zon/parse.zig Outdated
Comment thread lib/std/zon/parse.zig Outdated
@MasonRemaley

MasonRemaley commented Mar 15, 2025 •

Copy link
Copy Markdown
Contributor

(Appreciate the tests covering @"..." and putting it behind an option btw, I expected to make those suggestions then saw that you already did both haha.)

@MasonRemaley MasonRemaley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

std.zon: rename enum_literals_as_strings

Co-authored-by: Mason Remaley <MasonRemaley@users.noreply.github.com>

format embedded zon

move down new tests to enum tests
@dasimmet
dasimmet force-pushed the mr/enum-literal-as-string branch from de3983f to 28b3042 Compare October 26, 2025 23:21
@andrewrk andrewrk self-assigned this Nov 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants