[ https://issues.apache.org/jira/browse/THRIFT-2955?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14304136#comment-14304136 ]
Hudson commented on THRIFT-2955: -------------------------------- FAILURE: Integrated in Thrift #1445 (See [https://builds.apache.org/job/Thrift/1445/]) THRIFT-2955 Using list of typedefs does not compile on Go (jensg: rev 12d430e723b020f7a8ce42a40c19edf88f948367) * compiler/cpp/src/generate/t_go_generator.cc THRIFT-2955 Using list of typedefs does not compile on Go (jensg: rev 2663ec43ab5954d65d4bfb1509d963ac40019789) * compiler/cpp/src/generate/t_go_generator.cc > Using list of typedefs does not compile on Go > --------------------------------------------- > > Key: THRIFT-2955 > URL: https://issues.apache.org/jira/browse/THRIFT-2955 > Project: Thrift > Issue Type: Bug > Components: Go - Compiler > Affects Versions: 0.9.2 > Environment: Using golang 1.4 on linux/amd64 > Reporter: Johannes Martinsson > Assignee: Jens Geyer > Fix For: 0.9.3 > > Attachments: 0001-Be-explicit-about-when-to-use-true-type.patch, > THRIFT-2955-Using-list-of-typedefs-does-not-compile-(master).patch > > > Using a list with a typedefed value in a struct does not generate compilable > Go code. > Here is a small example definition which generates uncompilable code on at > least 0.9.2 and git master (as of the reporting of this issue). > {code:thrift} > namespace go poc > typedef i64 X > struct Y { > 1: list<X> xs > } > {code} > I've extracted some of the relevant snippets of code from the generated Go > code. > {code:go} > type X int64 > type Y struct { > Xs []int64 `thrift:"xs,1" json:"xs"` > } > func (p *Y) ReadField1(ipot thrift.TProtocol) error { > tSlice := make([]int64, 0, size) > for i := 0; i < size; i++ { > var _elem0 X > // _elem0 declared as X above > // [...] > temp := X(v) > _elem0 = temp > // [...] > // Trying to append _elem0 (of type X) to p.Xs of type []int64 > p.Xs = append(p.Xs, _elem0) > } > } > {code} > The issue is that the code is trying to append the typedefed type to a list of > the underlying type. I.e. appending {{X}} to a list of {{int64}}. > Smallest code change to make the generated code work is to cast {{_elem0}} to > {{int64}} in the {{append}} operation. However it might be better to actually > have {{p.Xs}} be of type {{[]X}} rather than {{[]int64}}. > (Currently I'm manually patching my generated Go code with type casts before > appending to these lists.) -- This message was sent by Atlassian JIRA (v6.3.4#6332)