-
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: inconsistent name resolution behavior #6296
Comments
"always error when finding a declaration of the wrong type" seems like the more desirable behavior. At the minimum, it would highlight that there are some confusing types there, instead of magically resolve to some random type. If we make it to always error, how many things will break? |
FWIW, method input and output names behave the same as extendee -- resolution of these names does not skip over non-type elements as is done for field types. |
Same goes for extension name resolution, when resolving option names. Though there is no "ResolveMode" that would work for this (i.e. there is no "LOOKUP_EXTENSIONS" value). |
This is sort of related to #9550. Different root cause and symptom, but also about inconsistent behavior when it comes to resolving names from different contexts. |
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment. This issue is labeled |
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please reopen it. This issue was closed and archived because there has been no new activity in the 14 days since the |
Consider the following proto file:
There are two relative
M
references:optional M ...
extend M { ... }
Both relative
M
references occur within the.foo.bar.M
namespace.Per the C++ scoping rules, the following absolute names should be tried in the following order:
.foo.bar.M.M
.foo.bar.M
.foo.M
.M
In our situation, both
.foo.bar.M.M
and.foo.bar.M
are legal declarations.However, the way resolution is handled is odd:
optional M ...
, it first finds.foo.bar.M.M
, which is an enum value type. Since it's looking for an enum or message type, it ignore this. It continues on to then find.foo.bar.M
. Since this is a message type, it returns that declaration.extend M ...
, it first finds.foo.bar.M.M
, which is an enum value type. Since it's looking for a message type, it throws an error complaining that it found the wrong type.This is inconsistent. The relative name resolution logic should either:
What is the right behavior?
The text was updated successfully, but these errors were encountered: