Andrii Degtiarov created THRIFT-4173:
----------------------------------------
Summary: Go: thrift compiler generates wrong code for list of
aliased type
Key: THRIFT-4173
URL: https://issues.apache.org/jira/browse/THRIFT-4173
Project: Thrift
Issue Type: Bug
Components: Compiler (General)
Affects Versions: 0.10.0
Environment: Linux amd64/Mac OS Sierra
Reporter: Andrii Degtiarov
Thrift code bellow produced incorrect Go code.
In the generated code {noformat}var _elem1 int8{noformat} should be
{noformat}var _elem1 StatType{noformat} and {noformat}temp := int8(v){noformat}
should be {noformat}temp := StatType(v){noformat}
Thrift:
{code:thrift}
typedef i8 StatType
struct SomeStruct {
1: list<StatType> stats;
}
{code}
Generated code:
{code:go}
func (p *CSVAnalyzeTaskPayload) ReadField1(iprot thrift.TProtocol) error {
_, size, err := iprot.ReadListBegin()
if err != nil {
return thrift.PrependError("error reading list begin: ", err)
}
tSlice := make([]StatType, 0, size)
p.Stats = tSlice
for i := 0; i < size; i ++ {
var _elem1 int8
if v, err := iprot.ReadByte(); err != nil {
return thrift.PrependError("error reading field 0: ", err)
} else {
temp := int8(v)
_elem1 = temp
}
p.Stats = append(p.Stats, _elem1)
}
if err := iprot.ReadListEnd(); err != nil {
return thrift.PrependError("error reading list end: ", err)
}
return nil
}
{code}
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)