[ 
https://issues.apache.org/jira/browse/THRIFT-895?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12908086#action_12908086
 ] 

Bryan Duxbury commented on THRIFT-895:
--------------------------------------

Spoke with David in IRC. We can make an acceptable C++ enum solution that looks 
like this:

{code}
class Foo {
  public: enum type {A=1, B=2};
};
{code}

Then, you can reference the enum type via Foo::type and the enum values via 
Foo::A and Foo::B. This means the only thing that users will need to change is 
the reference from Foo to Foo::type.

The Erlang stuff can be fixed as was already proposed.

More generally, this means that we'll be specifying clearly that we support 
this kind of functionality. That is, our enums will be more Java-like than 
C-like.

David is going to work up a patch.

> Thrift compiler does not allow two different enumerations to have the same 
> key name for one of the enum values
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: THRIFT-895
>                 URL: https://issues.apache.org/jira/browse/THRIFT-895
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (General)
>    Affects Versions: 0.4
>            Reporter: Tony Kinnis
>            Assignee: Bryan Duxbury
>            Priority: Critical
>             Fix For: 0.5
>
>         Attachments: test.thrift
>
>
> As of version 0.4.0 the Thrift compiler no longer allows two different enums 
> to have a key with the same name. It seems that this change was introduced by 
> the patch for THRIFT-544. Particularly the patch labeled: 
> thrift-544_prevent_redefining_consts.patch.
> The problem with this patch is that it now blocks this seemingly valid 
> definition.
> enum Foo {
>     A=1,
>     B=2
> }
> enum Bar {
>     A=1,
>     B=2
> }
> If I then run the thrift compiler as follows....
> thrift --gen java test.thrift 
> It will tell me that: test.thrift:7] Enum A is already defined!
> However, this should be valid and has worked in previous versions of Thrift. 
> I believe this patch (thrift-544_prevent_redefining_consts.patch) should be 
> rolled back.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to