Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"extend" is not allowed in proto3 spec, but is used in tests #4610

Closed
stepancheg opened this issue May 10, 2018 · 7 comments
Closed

"extend" is not allowed in proto3 spec, but is used in tests #4610

stepancheg opened this issue May 10, 2018 · 7 comments
Assignees

Comments

@stepancheg
Copy link

Spec 3 doesn't mention extend unlike Spec 2.

However extend with syntax = "proto3" is used in protobuf tests.

@TeBoring
Copy link
Contributor

Only MessageOption, which is internal. Don't use it by yourself.

@stepancheg
Copy link
Author

@TeBoring unfortunately protobuf compiler protoc accepts this option. And I'm writing Rust implementation of protobuf, and my implementation should be compatible with protoc.

If this option is not meant to be used outside of Google, then public version of protoc compiler should probably reject it.

@stepancheg
Copy link
Author

stepancheg commented May 14, 2018

%%% cat ./aaa.proto
syntax = "proto3";

import "google/protobuf/descriptor.proto";

message TestImportDescriptorProto {
  extend google.protobuf.MethodOptions {
    int32 a = 72295727;
  }
}

extend google.protobuf.MethodOptions {
  int32 a = 72295728;
}
%%% protoc --cpp_out=. ./aaa.proto
%%% protoc --version
libprotoc 3.5.0

@TeBoring TeBoring reopened this May 14, 2018
@TeBoring TeBoring added this to To Do in Weekly Fixit via automation May 14, 2018
@TeBoring
Copy link
Contributor

@anandolee, we can still define custom option in proto3, right?

@xfxyjwf
Copy link
Contributor

xfxyjwf commented May 14, 2018

In proto3, custom options are allowed, i.e., users can use "extend" keyword to define their own extensions to proto descriptor options. The spec is missing stuff because it was created after protoc, i.e., it's introduced to describe what protoc does, rather than defining what protoc does. If you are implementing protobuf support in a new language it's better to follow what protoc accepts instead of what the spec doc says.

@subfuzion
Copy link

subfuzion commented Jul 20, 2022

I know the issue is closed, but can the misleading title (which shows up in searches) be fixed? I believe now is supposed to be not.

@fowles fowles changed the title "extend" is now allowed in proto3 spec, but is used in tests "extend" is not allowed in proto3 spec, but is used in tests Jul 20, 2022
@fowles
Copy link
Member

fowles commented Jul 20, 2022

Fixed! (I hate that typo and am amazed how often I make it)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Weekly Fixit
  
Done
Development

No branches or pull requests

6 participants