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

Incorrect syntax for struct with enum property and default value when value is negative

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.7
    • None
    • C# - Compiler
    • None
    • Windows 7 / .net 4.0

    • Patch Available

    Description

      If I have a struct with a property of type enum with a default value specified, and the default value is negative, then the code generated is incorrect and has a syntax error.

      E.G. thrift file like this:

      enum ReturnType {
          SuccessTypeA = 2
          SuccessUnknownType = 1,
          FailUnknown = -1,
          OtherFailure = -2
      }
      
      struct ReturnInformation {
      	1: required ReturnType RetType = ReturnType.FailUnknown;
      }
      

      Generates a constructor like this:

          public MatchInformation() {
            this._MatchType = (MatchTypes)-1;
          }
      
      

      which fails with an exception "To cast a negative value, you must enclose the value in parentheses".

      I have updated the code to always put the enum constant value in parentheses (positive or negative), but need to get the compiler built and tested before I can submit a patch. Any chance someone could do this for me?

      Attachments

        Activity

          People

            jensg Jens Geyer
            slimunholyone Thunder Stumpges
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified