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

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development