[infinispan-issues] [JBoss JIRA] (IPROTO-101) Enum values with same name in different classes clash
Nistor Adrian (Jira)
issues at jboss.org
Thu Aug 1 07:08:00 EDT 2019
[ https://issues.jboss.org/browse/IPROTO-101?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13765743#comment-13765743 ]
Nistor Adrian commented on IPROTO-101:
--------------------------------------
Please test with this proto file by running it through protoc: {quote}protoc test_enums.proto -o/tmp/protoc_out.bin {quote}
{code}
// File test_enums.proto
package test_enums_package;
enum TestEnum1 {
YES = 1;
NO = 0;
MAYBE = 10;
}
enum TestEnum2 {
YES = 4;
NOPE = 5;
}
{code}
The output is self-explanatory (C++ scoping rules, the 80's are calling...):
{quote}
test_enums.proto:11:3: "YES" is already defined in "test_enums_package".
test_enums.proto:11:3: Note that enum values use C++ scoping rules, meaning that enum values are siblings of their type, not children of it. Therefore, "YES" must be unique within "test_enums_package", not just within "TestEnum2".
{quote}
> Enum values with same name in different classes clash
> -----------------------------------------------------
>
> Key: IPROTO-101
> URL: https://issues.jboss.org/browse/IPROTO-101
> Project: Infinispan ProtoStream
> Issue Type: Bug
> Affects Versions: 4.3.0.Alpha6
> Reporter: Ryan Emerson
> Assignee: Nistor Adrian
> Priority: Major
>
> {code:java}
> @ProtoName("TakeSiteOfflineResponse")
> public enum TakeSiteOfflineResponse {
> @ProtoEnumValue(number = 1)
> NO_SUCH_SITE,
> @ProtoEnumValue(number = 2)
> ALREADY_OFFLINE,
> @ProtoEnumValue(number = 3)
> TAKEN_OFFLINE
> }
> @ProtoName("BringSiteOnlineResponse")
> public enum BringSiteOnlineResponse {
> @ProtoEnumValue(number = 1)
> NO_SUCH_SITE,
> @ProtoEnumValue(number = 2)
> ALREADY_ONLINE,
> @ProtoEnumValue(number = 3)
> BROUGHT_ONLINE
> }
> {code}
> Results in:
> {code:java}
> Enum value org.infinispan.test.TakeSiteOfflineResponse.NO_SUCH_SITE clashes with enum value org.infinispan.test.BringSiteOnlineResponse.NO_SUCH_SITE
> {code}
--
This message was sent by Atlassian Jira
(v7.12.1#712002)
More information about the infinispan-issues
mailing list