Skip to content

Import bug - Message from Capitalized package is mistaken for Nested Type #87

@boukeversteegh

Description

@boukeversteegh

The compiler does not distinguish the following two cases:

package somepackage.Core;

message Message {}
package somepackage;

message Core {
  message Message {}
}

as they are both:

somepackage.Core.Message

Protoc (as far as I've been able to figure out) reports the full type name, but not which part of that is the package, and which is the real type (somepackage.Core: Message vs somepackage: Core.Message).

In 99% of cases, this will not be a problem, because if users will follow the Protobuf Style Guide, packages will be lowercase, and types CapitalCamelCase, and the distinction can be made based on that.

https://developers.google.com/protocol-buffers/docs/style#packages

Package name should be in lowercase, and should correspond to the directory hierarchy. e.g., if a file is in my/package/, then the package name should be my.package.

https://developers.google.com/protocol-buffers/docs/style?hl=cs-CZ#message-and-field-names

Use CamelCase (with an initial capital) for message names – for example, SongServerRequest. Use underscore_separated_names for field names (including oneof field and extension names) – for example, song_name.

Despite these style guides, there may be some users who are using Capitalized packages and for some reason cannot change the packages to lowercase.

Then, these packages will not be imported correctly from depending packages / messages.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghas testHas a (xfail) test that verifies the bugfix or featurelow priority

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions