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

double initialization in generated Read() method

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.9.2
    • Component/s: C# - Compiler
    • Labels:
      None

      Description

      IDL
      struct Element {
      	1: string foobar
      }
      
      struct Test {
      	1: list<Element>  elms
      }
      

      produces this code:

      Test.cs
      public partial class Test : TBase
      {
        //... stuff ...
      
        public void Read (TProtocol iprot)
        {
          //... stuff ...
              case 1:
                if (field.Type == TType.List) {
                  {
                    Elms = new List<Element>();
                    TList _list0 = iprot.ReadListBegin();
                    for( int _i1 = 0; _i1 < _list0.Count; ++_i1)
                    {
                      Element _elem2 = new Element();    // <-- first instance
                      _elem2 = new Element();            // <-- second instance
                      _elem2.Read(iprot);
                      Elms.Add(_elem2);
                    }
                    iprot.ReadListEnd();
                  }
            //... more stuff ...
      }
      

        Attachments

          Activity

            People

            • Assignee:
              jensg Jens Geyer
              Reporter:
              jensg Jens Geyer
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: