Thrift
  1. Thrift
  2. THRIFT-544

multiple enums with the same key generate invalid code

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 0.2
    • Fix Version/s: 0.4
    • Component/s: Compiler (General)
    • Labels:
      None
    • Patch Info:
      Patch Available

      Description

      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).

      EnumTest.thrift
      enum MyType1 {
        A = 0,
        B = 1
      }
      
      enum MyType2 {
        A = 2,
        C = 4
      }
      

      produces:

      enumTest_types.hrl
      -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.
      

      In the patched version, it produces this:

      enumTest_types.hrl
      -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.
      

        Activity

        Ben Taitelbaum created issue -
        Ben Taitelbaum made changes -
        Field Original Value New Value
        Attachment thrift-544_add_enum_name_to_enum_keys.patch [ 12414107 ]
        David Reiss made changes -
        Priority Major [ 3 ] Minor [ 4 ]
        Ben Taitelbaum made changes -
        Bryan Duxbury made changes -
        Component/s Compiler (General) [ 12312311 ]
        Component/s Compiler (Erlang) [ 12312389 ]
        Todd Lipcon made changes -
        Affects Version/s 0.2 [ 12313769 ]
        Affects Version/s 0.1 [ 12313284 ]
        Fix Version/s 0.3 [ 12314451 ]
        Fix Version/s 0.1 [ 12313284 ]
        Bryan Duxbury made changes -
        Fix Version/s 0.4 [ 12314960 ]
        Fix Version/s 0.3 [ 12314451 ]
        Bryan Duxbury made changes -
        Status Open [ 1 ] Closed [ 6 ]
        Assignee Ben Taitelbaum [ coshx ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Ben Taitelbaum
            Reporter:
            Ben Taitelbaum
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development