You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@thrift.apache.org by "Sylwester Lachiewicz (Jira)" <ji...@apache.org> on 2026/10/14 06:47:00 UTC
[jira] [Updated] (THRIFT-6391) Go -remote stub's local variable 'client' shadows an included package named client, so the stub does not compile
[ https://issues.apache.org/jira/browse/THRIFT-6391?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sylwester Lachiewicz updated THRIFT-6391:
-----------------------------------------
Fix Version/s: 0.26.0
> 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.24.0, 0.25.0
> Reporter: Sylwester Lachiewicz
> Priority: Minor
> Fix For: 0.26.0
>
> Time Spent: 1.5h
> Remaining Estimate: 0h
>
> 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)