Skip to content

Spec for options in protobuf language syntax is incomplete #8436

@jroper

Description

@jroper

I'm not sure where this documentation is hosted, but the following specifications for the protobuf language:

https://developers.google.com/protocol-buffers/docs/reference/proto2-spec
https://developers.google.com/protocol-buffers/docs/reference/proto3-spec

Are incomplete, they say nothing about the syntax of message literals when used in options. For example, this example from the developer guide for options:

optional int32 b = 2 [(foo_options) = { opt1: 123 opt2: "baz" }];

Is, according to the specs referenced above, not valid protobuf syntax, which specifies options as:

option = "option" optionName  "=" constant ";"
optionName = ( ident | "(" fullIdent ")" ) { "." ident }
constant = fullIdent | ( [ "-" | "+" ] intLit ) | ( [ "-" | "+" ] floatLit ) | strLit | boolLit 

This matters because right now I've encountered a problem in the JavaScript protocol buffers support where it differs in its opinion of what is valid syntax for message literals in options from protoc, but where does the bug lie? In protoc, or in the JavaScript protobuf parser? And even if we establish which one the bug lies in, what is the correct behavior? Without a spec that specifies what the correct syntax is, neither has a bug, and there's no way to resolve it because there's no correct behavior defined.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions