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

IDL Union structs nil dereferencing in Go

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Cannot Reproduce
    • 0.9.2
    • None
    • Go - Compiler

    Description

      Suppose I have a union

      union Select {
          1: Aggregate selectAggregate,
          2: SelectColumns selectColumns,
      }
      

      the Go representation looks like

      type Select struct {
      	SelectAggregate *Aggregate     `thrift:"selectAggregate,1" json:"selectAggregate"`
      	SelectColumns   *SelectColumns `thrift:"selectColumns,2" json:"selectColumns"`
      }
      

      now when I create

      Select = NewSelect()
      Select.SelectColumns = SelectColumns{
      ...
      }
      

      I get a nil dereference pointer when the code tries to invoke
      select.SelectAggregate.writeField1()

      however if I create a empty aggregate instantiation I get the error:

      Cannot read a TUnion with more than one set value!

      Attachments

        Activity

          People

            Unassigned Unassigned
            jseaidoun Jamil
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: