You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "David Reiss (JIRA)" <ji...@apache.org> on 2009/07/21 19:30:14 UTC

[jira] Commented: (THRIFT-544) multiple enums with the same key generate invalid code

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

David Reiss commented on THRIFT-544:
------------------------------------

This is an error in C as well, which is what Thrift's enums are based on.  So I think the real solution is to throw an error at code generation time.

> multiple enums with the same key generate invalid code
> ------------------------------------------------------
>
>                 Key: THRIFT-544
>                 URL: https://issues.apache.org/jira/browse/THRIFT-544
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (Erlang)
>    Affects Versions: 0.1
>            Reporter: Ben Taitelbaum
>             Fix For: 0.1
>
>         Attachments: thrift-544_add_enum_name_to_enum_keys.patch
>
>
> The current generator produces multiple -define statements with the same name, which isn't valid erlang code (and also isn't valid semantically if we want two different values).
> {code:title=EnumTest.thrift|borderStyle=solid}
> enum MyType1 {
>   A = 0,
>   B = 1
> }
> enum MyType2 {
>   A = 2,
>   C = 4
> }
> {code}
> produces:
> {code:title=enumTest_types.hrl|borderStyle=solid}
> -ifndef(_enumTest_types_included).
> -define(_enumTest_types_included, yeah).
> -define(enumTest_A, 0).
> -define(enumTest_B, 1).
> -define(enumTest_A, 2).
> -define(enumTest_C, 4).
> -endif.
> {code}
> In the patched version, it produces this:
> {code:title=enumTest_types.hrl|borderStyle=solid}
> -ifndef(_enumTest_types_included).
> -define(_enumTest_types_included, yeah).
> -define(enumTest_MyType1_A, 0).
> -define(enumTest_MyType1_B, 1).
> -define(enumTest_MyType2_A, 2).
> -define(enumTest_MyType2_C, 4).
> -endif.
> {code}

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