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

[jira] Updated: (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:all-tabpanel ]

Ben Taitelbaum updated THRIFT-544:
----------------------------------

    Attachment: thrift-544_prevent_redefining_consts.patch

Here's a really simple patch that prevents multiple constants with the same name.

> 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
>            Priority: Minor
>             Fix For: 0.1
>
>         Attachments: thrift-544_add_enum_name_to_enum_keys.patch, thrift-544_prevent_redefining_consts.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.