spec: RFC-001 contextual keywords (no soft-break for v1.2) - #71
Merged
Conversation
Amends RFC-001 to make `type`, `function`, and `annotation`
contextual keywords — recognized only at the start of a top-level
declaration; accepted as identifiers everywhere else. Removes the
soft-break that the original v1.2 reservation would have introduced.
Discovery driving the change: implementation pre-flight surfaced
`oneof type { ... }` in Google's Cloud DLP API schema (Apache 2.0,
vendored in protocompile/parser/testdata/largeproto.proto, 8
occurrences) and many production schemas. Hard-reserving the words
would break wide swaths of real-world protobuf code, including
Google's own APIs. Contextual keywords preserve every v1.1 schema
unchanged.
Also drops the spurious reservations of `expression` (only meaningful
in annotation-parameter-type position) and `this` (only inside
engine-language bodies, which protocompile captures opaquely). Reduces
the touched-tokens count from 5 to 3.
Pattern is well-precedented — Java 9 added `module`, `requires`,
`exports`, `opens`, `to`, `with` as contextual keywords for exactly
this reason.
Files:
- docs/RFC-001-schema-extensions.md contextual-keyword design + rationale
- docs/draft-trendvidia-protowire-01.md Reserved Keywords + ABNF appendix
- STABILITY.md no source-level incompatibility for v1.2
- CHANGELOG.md updated v1.2.0 notes
- docs/M1-kickoff-protocompile.md PR 1 scope adjusted to 3 keywords +
contextual-keyword grammar bridge;
estimate revised 1-2 days -> 2-3 days
Bundled into this PR (was originally just the kickoff doc) because the
kickoff scope only makes sense after the amendment; reviewing them as
one is cleaner than two sequential PRs against an unmerged base.
trendvidia
force-pushed
the
m1-kickoff-doc
branch
from
June 5, 2026 22:16
5b9d44c to
e441cea
Compare
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Amends RFC-001 to make
type,function, andannotationcontextual keywords — recognized only at the start of a top-level declaration; accepted as identifiers everywhere else. Removes the soft-break that the original v1.2 reservation would have introduced.Also drops the spurious reservations of
expression(only meaningful in annotation-parameter-type position) andthis(only inside engine-language bodies, which protocompile captures opaquely). Reduces the touched-tokens count from 5 to 3.Follow-up to #54 (RFC corpus) and #70 (M1 kickoff doc). Tracked by #55.
What surfaced this
The M1 implementation pre-flight surfaced
oneof type { ... }in Google's Cloud DLP API schema (Apache 2.0, vendored atparser/testdata/largeproto.protoinprotocompile, 8 occurrences). The pattern is common across production protobuf schemas in the wild, including Google's own gRPC APIs.Hard-reserving the words would break wide swaths of real-world protobuf code. Contextual recognition preserves every v1.1 schema unchanged — the parser uses the file-scope production's lookahead to distinguish
type Email = ...(keyword) fromoneof type { ... }(identifier).Pattern is well-precedented: Java 9 added
module,requires,exports,opens,to,withas contextual keywords for the same reason.What this PR changes
docs/RFC-001-schema-extensions.mdexpressionandthisdocs/draft-trendvidia-protowire-01.mdSTABILITY.mdCHANGELOG.md[Unreleased]entry — contextual-keyword notedocs/M1-kickoff-protocompile.mdBackward compatibility
After this amendment, the wire and semantic compatibility statements simplify:
The migration story moves from "rename any identifier that collides" to "nothing changes."
Test plan
_NAMEname-binding positions inprotocompile/parser/proto.y