Skip to content

parser: accept group inside oneof. - #41

Merged
VeaaC merged 1 commit into
mainfrom
group-in-oneof-2.13
Aug 12, 2026
Merged

parser: accept group inside oneof.#41
VeaaC merged 1 commit into
mainfrom
group-in-oneof-2.13

Conversation

@VeaaC

@VeaaC VeaaC commented Aug 11, 2026

Copy link
Copy Markdown
Owner

group is legal as a oneof member (spec: OneofGroupDecl), but rapidprotoc rejected the
whole schema with unexpected input. A oneof is not a scope, so parse_oneof now returns an
OneofBundle — mirroring the existing ExtendBundle — and the synthesized message hoists to
the enclosing message while the delimited field joins the oneof. parse_oneof moved into
parser.cpp's anonymous namespace alongside parse_extend, which was never public.

Aligning the two element lists it touches against
the grammar removed two stray acceptances:

  • ; between oneof members. MessageElement lists EmptyDecl; OneofElement does not.
  • ; or an option in an extend body. ExtensionElement is the only element list
    carrying neither. That is deliberate: ExtensionFieldDeclIdentifier subtracts only the
    cardinality keywords, not option — so option is a legal extension-field type name
    there, and the OptionDecl branch was misparsing extend M { option x = 100; } as an
    option declaration. ExtendNode::options is removed with it; the only consumer was a
    resolve_extend call that could never fire.

A labelled oneof member is refused with protoc's own wording, at protoc's exact column
(previously unexpected input, pointing past the label). oneof p { optional x = 1; } in a
file declaring a message named optional is now correctly rejected rather than parsed as a
field of that type. An empty oneof body stays accepted: the grammar admits it, and the
prose rule requiring one member is a semantic check we don't make.

@VeaaC
VeaaC force-pushed the group-in-oneof-2.13 branch 2 times, most recently from 1802d9b to b244f21 Compare August 12, 2026 05:01
@VeaaC VeaaC changed the title parser: accept group inside oneof, which protoc allows parser: accept group inside oneof. Aug 12, 2026
@VeaaC
VeaaC force-pushed the group-in-oneof-2.13 branch from b244f21 to 99536fd Compare August 12, 2026 16:21
@VeaaC
VeaaC merged commit f34d684 into main Aug 12, 2026
9 checks passed
@VeaaC
VeaaC deleted the group-in-oneof-2.13 branch August 12, 2026 17:04
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.

1 participant