[
https://issues.apache.org/jira/browse/THRIFT-6200?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Sylwester Lachiewicz updated THRIFT-6200:
-----------------------------------------
Summary: Go -remote stub qualifies enum and inherited container arguments
with the wrong package when they come from an included file (was: Go -remote
stub qualifies an enum argument with the wrong package when the enum comes from
an included file)
> Go -remote stub qualifies enum and inherited container arguments with the
> wrong package when they come from an included file
> ----------------------------------------------------------------------------------------------------------------------------
>
> Key: THRIFT-6200
> URL: https://issues.apache.org/jira/browse/THRIFT-6200
> Project: Thrift
> Issue Type: Bug
> Components: Go - Compiler
> Reporter: Sylwester Lachiewicz
> Priority: Major
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> The Go {{-remote}} stub qualifies an enum argument with the package of the
> service, not the package the enum is declared in, so the stub does not
> compile whenever a service method takes an enum from an included file.
> h3. Reproduction
> {{lib/go/test/IncludesTest.thrift}} already has the shape:
> {code}
> include "ThriftTest.thrift"
> service testService extends ThriftTest.SecondService {
> ThriftTest.CrazyNesting getCrazyNesting(
> 1: ThriftTest.StructA a,
> 2: ThriftTest.Numberz numbers
> ) throws(1: ThriftTest.Xception err1),
> }
> {code}
> {{Numberz}} is declared in {{ThriftTest.thrift}} and generated into the
> {{thrifttest}} package, but the stub reaches for it in {{includestest}}:
> {code:go}
> tmp1, err := (strconv.Atoi(flag.Arg(2)))
> if err != nil {
> Usage()
> return
> }
> argvalue1 := includestest.Numberz(tmp1)
> {code}
> {noformat}
> gopath/src/includestest/test_service-remote/test_service-remote.go:179:29:
> undefined: includestest.Numberz
> gopath/src/includestest/extended_service-remote/extended_service-remote.go:197:29:
> undefined: includestest.Numberz
> {noformat}
> h3. Cause
> In {{t_go_generator::generate_service_remote}} the enum branch writes
> {{package_name_aliased}} unconditionally:
> {code:cpp}
> f_remote << indent() << "argvalue" << i << " := " << package_name_aliased <<
> "."
> << publicize(the_type->get_name()) << "(tmp" << i << ")" << '\n';
> {code}
> The struct branch a few lines below resolves the package with
> {{module_name()}} and falls back to {{package_name_aliased}} only when that
> is empty. The enum branch needs the same treatment.
> Unrelated to THRIFT-6197: the branch is unchanged by that work, and
> regenerating every IDL under test/, lib/go/test/ and tutorial/ with the
> released and the patched generator produces identical output for this file.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)