Sylwester Lachiewicz created THRIFT-6391:
--------------------------------------------

             Summary: Go -remote stub's local variable 'client' shadows an 
included package named client, so the stub does not compile
                 Key: THRIFT-6391
                 URL: https://issues.apache.org/jira/browse/THRIFT-6391
             Project: Thrift
          Issue Type: Bug
          Components: Go - Compiler
    Affects Versions: 0.25.0, 0.24.0
            Reporter: Sylwester Lachiewicz


The Go {{-remote}} stub declares its service client in a local variable named 
{{client}} 
([t_go_generator.cc|https://github.com/apache/thrift/blob/master/compiler/cpp/src/thrift/generate/t_go_generator.cc#L2895]).
 When the service uses a type from an included IDL file whose Go package is 
also named {{client}}, that variable shadows the package, and every later 
{{client.NewX()}} in the stub refers to the variable:

{noformat}
$ cat client.thrift
struct Info { 1: i32 x }
$ cat svc.thrift
include "client.thrift"
service Svc { void f(1: client.Info info) }
$ thrift -r --gen go svc.thrift && go build ./...
svc/svc-remote/svc-remote.go:163:23: client.NewInfo undefined (type 
*svc.SvcClient has no field or method NewInfo)
{noformat}

{noformat}
141:    client := svc.NewSvcClient(thrift.NewTStandardClient(iprot, oprot))
163:            argvalue0 := client.NewInfo()
{noformat}

Apache Accumulo's IDL has a client.thrift that its other files include, so all 
8 of its generated {{-remote}} packages fail to build this way, while its 
library packages build. The code is the same in 0.24.0, 0.25.0 and master. 
Found while testing THRIFT-6388.

Naming the variable something that cannot collide with a package name the 
generator produces, or with the aliases it already assigns to imports, would 
fix it.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to