develooper Front page | perl.perl5.porters | Postings from September 2018

[perl #133543] Fatalize my() in false conditional in perl-5.30

Thread Previous
James E Keenan
September 25, 2018 19:58
[perl #133543] Fatalize my() in false conditional in perl-5.30
Message ID:
# New Ticket Created by  James E Keenan 
# Please include the string:  [perl #133543]
# in the subject line of all future correspondence about this issue. 
# <URL: >

I am here creating a ticket for an item mentioned on the mailing list: 
the fatalization of my() in false conditional.  (I haven't found an 
existing RT for this item, though there does exist a META ticket.)

According to the perl-5.28.0 source code, the following deprecation is 
scheduled for perl-5.30:

op.c-8260-		&& o2->op_private & OPpLVAL_INTRO
op.c-8261-		&& !(o2->op_private & OPpPAD_STATE))
op.c-8262-	    {
op.c-8263-		Perl_ck_warner_d(aTHX_ packWARN(WARN_DEPRECATED),
op.c-8264-                                "Deprecated use of my() in 
false conditional. "
op.c:8265:                                "This will be a fatal error in 
Perl 5.30");
op.c-8266-	    }
op.c-8268-	    *otherp = NULL;
op.c-8269-	    if (cstop->op_type == OP_CONST)
op.c-8270-		cstop->op_private |= OPpCONST_SHORTCIRCUIT;

And that entails revision of this documentation:

pod/perldiag.pod-2017-(F) In a here document construct like C<<<FOO>, 
the label C<FOO> is too
pod/perldiag.pod-2018-long for Perl to handle.  You have to be seriously 
twisted to write code
pod/perldiag.pod-2019-that triggers this error.
pod/perldiag.pod:2021:=item Deprecated use of my() in false conditional. 
This will be a fatal error in Perl 5.30
pod/perldiag.pod-2023-(D deprecated) You used a declaration similar to 
C<my $x if 0>.  There
pod/perldiag.pod-2024-has been a long-standing bug in Perl that causes a 
lexical variable
pod/perldiag.pod-2025-not to be cleared at scope exit when its 
declaration includes a false
pod/perldiag.pod-2026-conditional.  Some people have exploited this bug 
to achieve a kind of
pod/perldiag.pod-2038-lexicals that are initialized only once (see 
pod/perldiag.pod-2040-    sub f { state $x; return $x++ }
pod/perldiag.pod-2042-This use of C<my()> in a false conditional has 
been deprecated since
pod/perldiag.pod:2043:Perl 5.10, and it will become a fatal error in 
Perl 5.30.
pod/perldiag.pod-2045-=item DESTROY created new reference to dead object 
pod/perldiag.pod-2047-(F) A DESTROY() method created a new reference to 
the object which is
pod/perldiag.pod-2048-just being DESTROYed.  Perl is confused, and 
prefers to abort rather

I will attach patches which constitute a (crude) first pass at 
implementing this fatalization.  This will be smoke-testing in a branch 
which I will push as soon as I get an RT number.

Thank you very much.
Jim Keenan

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About