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

John Boiles commented on THRIFT-4901:
-------------------------------------

[~calcifer] if you're able to handle this that'd be great. There's one more Go 
bug i'm working on a test case for -- something about the CLI -remote.go 
clients not compiling when you have a service that extends another service. My 
plan is to get that filed, then put up my branch to not use pointer to maps and 
slices ([follow up from 
#1802|https://github.com/apache/thrift/pull/1802#issuecomment-501501792])

> Go fails to compile when a struct field is a typedef to a struct
> ----------------------------------------------------------------
>
>                 Key: THRIFT-4901
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4901
>             Project: Thrift
>          Issue Type: Task
>          Components: Go - Compiler
>    Affects Versions: 0.13.0
>            Reporter: John Boiles
>            Priority: Major
>
> Given two thrift files:
> {code}
> # TypedefNamespaceTestA.thrift
> namespace go typedef.namespace.testa
> struct ThingA {
>   1: bool value
> }
> {code}
> {code}
> # TypedefNamespaceTestB.thrift
> include "TypedefNamespaceTestA.thrift"
> typedef TypedefNamespaceTestA.ThingA TThingA
> struct ThingB {
>   1: TThingA value
> }
> {code}
> The Thrift Go compiler generates code like:
> {code:go}
> type TThingA *testa.ThingA
> type ThingB struct {
>   Value *TThingA `thrift:"value,1" db:"value" json:"value"`
> }
> // ...irrelevant code omitted...
> func (p *ThingB)  ReadField1(iprot thrift.TProtocol) error {
>   p.Value = &testa.ThingA{} // Fails to compile
>   if err := p.Value.Read(iprot); err != nil { // Fails to compile
> // ...irrelevant code omitted...
> func (p *ThingB) writeField1(oprot thrift.TProtocol) (err error) {
>   if err := oprot.WriteFieldBegin("value", thrift.STRUCT, 1); err != nil {
>     return thrift.PrependError(fmt.Sprintf("%T write field begin error 
> 1:value: ", p), err) }
>   if err := p.Value.Write(oprot); err != nil { // Fails to compile
>     return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", 
> p.Value), err)
>   }
> // ...irrelevant code omitted...
> {code}
> This causes the following build failures:
> {code}
> gopath/src/typedefnamespacetestb/TypedefNamespaceTestB.go:88:11: cannot use 
> &testa.ThingA literal (type *testa.ThingA) as type *TThingA in assignment
> gopath/src/typedefnamespacetestb/TypedefNamespaceTestB.go:89:20: p.Value.Read 
> undefined (type *TThingA has no field or method Read)
> gopath/src/typedefnamespacetestb/TypedefNamespaceTestB.go:111:20: 
> p.Value.Write undefined (type *TThingA has no field or method Write)
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to