[
https://issues.apache.org/jira/browse/THRIFT-4365?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16212132#comment-16212132
]
ASF GitHub Bot commented on THRIFT-4365:
----------------------------------------
GitHub user finncolman opened a pull request:
https://github.com/apache/thrift/pull/1393
THRIFT-4365: Replaced indirect object syntax
Don't use indirect object syntax as it can cause compilation errors in some
cases.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/finncolman/thrift THRIFT-4365
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/thrift/pull/1393.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #1393
----
commit b138e70016a04c3f373b6680eb265f196e1f08bc
Author: root <root@local-email-dispatcher-client>
Date: 2017-10-20T04:15:21Z
THRIFT-4365: Replaced indirect object syntax
----
> Perl generated code uses indirect object syntax, which occasionally causes
> compilation errors.
> ----------------------------------------------------------------------------------------------
>
> Key: THRIFT-4365
> URL: https://issues.apache.org/jira/browse/THRIFT-4365
> Project: Thrift
> Issue Type: Bug
> Components: Perl - Compiler
> Affects Versions: 0.10.0
> Reporter: Finn Isaac Norris Colman
> Labels: easyfix
>
> When running the Thrift compiler for Perl the automatically generated code
> uses "Indirect Object Syntax". So the generated code looks like this:
> {noformat}
> $self->{success} = new contact_types::Response();
> {noformat}
> It should look like this:
> {noformat}
> $self->{success} = contact_types::Response->new();
> {noformat}
> I found in some cases the indirect object syntax can actually cause failures
> because Perl gets confused and thinks Response is a subroutine, with an error
> like this:
> {noformat}
> Undefined subroutine &user_types::Response called at gen-perl/user/Service.pm
> line 131.
> {noformat}
> If you look in https://perldoc.perl.org/perlobj.html under the "Indirect
> Object Syntax" heading, you see it says:
> "Outside of the file handle case, use of this syntax is discouraged as it can
> confuse the Perl interpreter. See below for more details.".
> Fixing this problem should be straight forward. In the
> https://github.com/apache/thrift/blob/master/compiler/cpp/src/thrift/generate/t_perl_generator.cc
> it should instead of doing this:
> {noformat}
> out << indent() << "$" << prefix << " = new " <<
> perl_namespace(tstruct->get_program())
> << tstruct->get_name() << "();" << endl << indent() << "$xfer += $" <<
> prefix
> << "->read($input);" << endl;
> {noformat}
> Do this:
> {noformat}
> out << indent() << "$" << prefix << " = " <<
> perl_namespace(tstruct->get_program())
> << tstruct->get_name() << "->new();" << endl << indent() << "$xfer +=
> $" << prefix
> << "->read($input);" << endl;
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)