[ 
https://issues.apache.org/jira/browse/THRIFT-4173?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17067285#comment-17067285
 ] 

Zezeng Wang edited comment on THRIFT-4173 at 3/26/20, 1:38 AM:
---------------------------------------------------------------

*typedef i8 StatType*

*struct SomeStruct {*
 *1: list<StatType> stats;*
 *}*

 

The .thirft file use *typedef* can generate correct code which use *StatType* 
rather than  *int8* (both C++ and go).


was (Author: zeshuai007):
*typedef i8 StatType*

*struct SomeStruct {*
 *1: list<StatType> stats;*
*}*

 

The .thirft file use *typedef* can generate correct code which use *StatType* 
rather than ** int8 (both C++ and go).

> 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
>            Priority: Major
>
> 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}
> typedef i8 StatType
> struct SomeStruct {
>  1: list<StatType> stats;
> }
> {code}
> Generated code:
> {code}
> 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
(v8.3.4#803005)

Reply via email to