-
Notifications
You must be signed in to change notification settings - Fork 15.5k
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
protoc: support inf, -inf, nan, and -nan in option values #15017
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the fix and sorry for taking so long to get to this. This looks great to me but would you mind also adding some examples to unittest_custom_options.proto and another short unit test case in parser_unittest.cc that checks that we can read the correct values for those options? I think it would be good to just have test coverage that validates the options after they're interpreted.
We triage inactive PRs and issues in order to make it easier to find active work. If this PR should remain active, please add a comment. This PR is labeled |
f130ac9
to
475cd68
Compare
@acozzette, sorry for the long hiatus from the branch! This was a good idea since I totally messed up my original change and forgot to actually update the options interpreting step to allow identifiers "inf" and "nan" for double and float values 🤦. I've done as requested... but the new test case in parser_unittest.cc is really complicated. We can't easily extract values from a parsed/linked descriptor since interpreting options stores them in the unrecognized field set. So we have to serialize and de-serialize them. I'm using a dynamic message to avoid issues where the Anyhow. I wonder if this new test is really necessary? There is an existing test ( |
@jhump How about a test that just looks at the generated descriptors from the protos you added in unittest_custom_options.proto and verifies that the options have the expected values? That should be a lot simpler because then you can just rely on the generated descriptor pool instead of building your own. |
@acozzette, okay, I've replaced the complicated test with that. Definitely simpler. |
@acozzette, where does this PR go from here? Does it need to be tested internally before it can actually be merged? |
@jhump Sorry for the delay, I was out for a few days last week and lost track of this. Would you mind merging main into your PR (or rebasing)? I'm hitting an issue syncing it into our internal system which I think should be fixed by that. After that it should be straightforward to test it internally and land the change. |
…pport for inf and nan in options interpreter
49ec659
to
1f8217c
Compare
@acozzette, done. |
@acozzette, yes, that would be the right fix (and what I will do in that repo as soon as this fix is released and that repo updated to use that latest |
As odd as it sounds, upstream supports this and there is a unittest that ensure it parses: https://github.com/protocolbuffers/protobuf/blob/3c03e9351c57081d0dffae120ed37497017f105c/src/google/protobuf/compiler/parser_unittest.cc#L464 It seems to have come from: protocolbuffers/protobuf#15017 So make sure Swift is also able to parse it.
As odd as it sounds, upstream supports this and there is a unittest that ensure it parses: https://github.com/protocolbuffers/protobuf/blob/3c03e9351c57081d0dffae120ed37497017f105c/src/google/protobuf/compiler/parser_unittest.cc#L464 It seems to have come from: protocolbuffers/protobuf#15017 So make sure Swift is also able to parse it. Also reflow some of the unknown field parsing as inf/nan don't need to be special cased with how the flow now works.
As odd as it sounds, upstream supports this and there is a unittest that ensure it parses: https://github.com/protocolbuffers/protobuf/blob/3c03e9351c57081d0dffae120ed37497017f105c/src/google/protobuf/compiler/parser_unittest.cc#L464 It seems to have come from: protocolbuffers/protobuf#15017 So make sure Swift is also able to parse it. Also reflow some of the unknown field parsing as inf/nan don't need to be special cased with how the flow now works.
…ffers#15017) The parser already supports these values for the special "default" field option. But, inconsistently, does not support them for other options whose type is float or double. This addresses that inconsistency. Fixes protocolbuffers#15010. Closes protocolbuffers#15017 COPYBARA_INTEGRATE_REVIEW=protocolbuffers#15017 from jhump:jh/inf-and-nan-in-option-values 1f8217c PiperOrigin-RevId: 627399259
The parser already supports these values for the special "default" field option. But, inconsistently, does not support them for other options whose type is float or double. This addresses that inconsistency.
Fixes #15010.