Skip to content

Implement custom message field defaults#611

Merged
mcy merged 17 commits into
mainfrom
mcy/default-value
Oct 17, 2025
Merged

Implement custom message field defaults#611
mcy merged 17 commits into
mainfrom
mcy/default-value

Conversation

@mcy

@mcy mcy commented Oct 16, 2025

Copy link
Copy Markdown
Member

This PR implements the other field pseudo-option, default.

To make this work, I've refactored how pseudo-options are built to be more similar to normal options. Specifically, this is so that the (invalid) [default.foo = 1] syntax works for message-typed fields.

I also added UTF-8 validation of options whose corresponding fields require UTF-8 validation, according to features. Interestingly, default uniquely does not go through this check; in that case, a warning (pointing out that protoc accepts this by mistake) is issued instead.

mcy and others added 15 commits October 15, 2025 15:05
This adds all the deprecation warnings you would ever want, based on the
`deprecated` option on most things in Protobuf. This triggers when:

1. Importing a deprecated file.
2. Referencing a deprecated type from another file as a field or method
signature type.
3. Using an option whose corresponding field is deprecated.
4. Using a deprecated enum value in an option.
This fixes the bounds check to avoid overflowing the untyped int on
32-bit systems. Overflows on const conversion of `math.MaxUint32`.
…596)

This validates that:

- `features.utf8_validation` is only used on string fields.
- `features.message_encoding` is only used on length-prefixed message
fields.
This adds missing validation for `reserved` names.
@mcy
mcy marked this pull request as ready for review October 17, 2025 18:52
@mcy
mcy requested a review from emcfarlane October 17, 2025 18:52
@mcy
mcy merged commit c38c07a into main Oct 17, 2025
6 checks passed
@mcy
mcy deleted the mcy/default-value branch October 17, 2025 19:56
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.

2 participants