Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-544

multiple enums with the same key generate invalid code

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 0.2
    • 0.4
    • Compiler (General)
    • None
    • 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.
      

      Attachments

        1. thrift-544_prevent_redefining_consts.patch
          0.5 kB
          Ben Taitelbaum
        2. thrift-544_add_enum_name_to_enum_keys.patch
          0.6 kB
          Ben Taitelbaum

        Activity

          People

            coshx Ben Taitelbaum
            coshx Ben Taitelbaum
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: