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

Resolution of imported names #164

Open
j6carey opened this issue Jul 15, 2021 · 0 comments
Open

Resolution of imported names #164

j6carey opened this issue Jul 15, 2021 · 0 comments
Labels

Comments

@j6carey
Copy link
Collaborator

j6carey commented Jul 15, 2021

Name resolution in compile-proto-file deviates from that of protoc and from this portion of the specification:

https://developers.google.com/protocol-buffers/docs/proto3#packages_and_name_resolution

Specifically, compile-proto-file allows unqualified lookup of imported names, which seems to be nonstandard, but fails to find qualified names unless they start at the top package component. It should look up both qualified and unqualified names relative to the current package, its parent package, and so forth, on up to the root--except for names that start with a period, which are always relative to the root (that is, absolute).

Consider the following two test inputs:

$ cat test1.proto 
syntax = "proto3";
package test.sub1;
message Message1 {}

$ cat test2.proto 
syntax = "proto3";
package test.sub2;
import "test1.proto";
message Message2 { sub1.Message1 sub = 1; }

protoc accepts test2.proto, but rejects it if we remove the sub1. qualification from the reference to Message1.

By contrast, compile-proto-file rejects test2.proto:

compile-proto-file --proto test2.proto --out t
Error: failed to compile "test2.proto":

NoSuchType (Dots (Path {components = "sub1" :| ["Message1"]}))

But if we remove the sub1 qualification then then compile-proto-file succeeds--even though protoc would fail in that case.

If we expand qualification to test.sub1.Message1 or the absolute path .test.sub1.Message1 then both compile-proto-file and protoc accept the input.

@j6carey j6carey added the bug label Jul 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant