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

double initialization in generated Read() method

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 0.9.2
    • C# - Compiler
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: