In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/bfc60ea21e7aaed22d534045f4097593ec21898a?hp=f6cce60a032fd351c1c7a6961fd3bcb043b3a784>
- Log ----------------------------------------------------------------- commit bfc60ea21e7aaed22d534045f4097593ec21898a Author: Father Chrysostomos <[email protected]> Date: Sun Aug 31 06:53:34 2014 -0700 perldelta for 8b57a5fa M pod/perldelta.pod commit 7e8b2071f49f87aa242d6859705f08f87b66c2aa Author: Father Chrysostomos <[email protected]> Date: Sun Aug 31 06:52:01 2014 -0700 perldelta for 211a4342 M pod/perldelta.pod commit 1699f5c257bc554753cc4ddf10c62ac8a5c338ff Author: Father Chrysostomos <[email protected]> Date: Sun Aug 31 06:50:17 2014 -0700 perldelta for f20d0df0f M pod/perldelta.pod commit be0006e0bb9fb246622a16b5f6ad9957cc6c8d36 Author: Father Chrysostomos <[email protected]> Date: Sun Aug 31 06:47:13 2014 -0700 perldelta for 4dda930be/#122556 M pod/perldelta.pod commit 432027c86cdf864c1efc368c39c1f4834704adb0 Author: Father Chrysostomos <[email protected]> Date: Sun Aug 31 06:45:38 2014 -0700 perldelta: A to-do item Mostly my own reminder, because I have not rebased yet, and this entry will conflict with something already pushed. M pod/perldelta.pod commit 549ea8d47231cbd5801b63a9cadc5a2e430180b3 Author: Father Chrysostomos <[email protected]> Date: Sun Aug 31 06:44:18 2014 -0700 perldelta for 8380b6901 M pod/perldelta.pod commit 6f1a844b691a221b5cb07e1f727f6874735f9cc2 Author: Father Chrysostomos <[email protected]> Date: Sun Aug 31 06:42:29 2014 -0700 perldelta for acb187b49 (part of #69456) M pod/perldelta.pod commit 0aa1826c09de34f9dda9874230159d250138c38e Author: Father Chrysostomos <[email protected]> Date: Sun Aug 31 06:39:27 2014 -0700 perldelta for eff754733a9 M pod/perldelta.pod commit 07ec6dc6c1e9a3a06ac5059d954fcec1dde7945d Author: Father Chrysostomos <[email protected]> Date: Sun Aug 31 06:35:55 2014 -0700 perldelta for #80368/e4916dd1b3 M pod/perldelta.pod commit 59e6df9f1cf4cd5c46c36d625e538b870dba7a22 Author: Father Chrysostomos <[email protected]> Date: Sun Aug 31 06:27:45 2014 -0700 Stop prototype declaration from clobbering constants $ perl -e 'use constant f=>3; sub f($); warn eval "&f"' Runaway prototype at -e line 1. Prototype mismatch:: none vs ($) at -e line 1. Undefined subroutine &main::f called at (eval 1) line 1. ...caught at -e line 1. $ perl -e 'sub f (){3} sub f($); warn eval "&f"' Prototype mismatch: sub main::f () vs ($) at -e line 1. 3 at -e line 1. (The âRunaway prototypeâ warning was removed in acfcf464b177, in which I stated wrongly that the warning could only come about with stash manipulation. I suppose the warning was really warning me that the implementation was broken, which it was until this commit.) When constant refs in the symbol table were introduced in 5.10.0 (a bisect points to e040ff70dc), one code path in newATTRSUB--that assumes that a stash entry that is not a GV is not a defined sub, but either a forward declaration or no sub at all--was not updated to account for this new way of storing constants. M op.c M t/op/sub.t commit 172a6a76e8c24d5e8b67519dedce8baeb429e5d0 Author: Father Chrysostomos <[email protected]> Date: Sat Aug 30 16:19:24 2014 -0700 Stop anon sub compilation from clobbering __ANON__ Anonymous subs point to *__ANON__ simply because internals expect defined subroutines to have CvGV pointing somewhere. So why does anonymous constant sub compilation wipe *__ANON__{CODE} clean? $ perl -e 'sub main::__ANON__ { 42 }; warn main::__ANON__; # sub(){3}' 42 at -e line 1. $ perl -e 'sub main::__ANON__ { 42 }; warn main::__ANON__; sub(){3}' Undefined subroutine &main::__ANON__ called at -e line 1. It doesnât happen with non-constant subs: $ perl -e 'sub main::__ANON__ { 42 }; warn main::__ANON__; sub{3}' 42 at -e line 1. This is actually a regression: ../perl.git/Porting/bisect.pl --end=perl-5.8.8 --target=miniperl -e 'sub main::__ANON__ { 42 }; warn main::__ANON__; sub(){3}' beab0874143b7208922720fecefc4a224011fa25 is the first bad commit commit beab0874143b7208922720fecefc4a224011fa25 Author: John Tobey <jtobey at john-edwin-tobey.org> Date: Fri Oct 20 18:03:27 2000 -0400 Re: Creating const subs for constants. Message-Id: <[email protected]> p4raw-id: //depot/perl@7389 The new code path for constants did an unconditional GvCV_set(gv, NULL), instead of checking whether there was a name first. M op.c M t/op/anonsub.t commit 625770c2add76d6556e6fa86833275b16a6ec50e Author: Father Chrysostomos <[email protected]> Date: Sat Aug 30 16:08:13 2014 -0700 Porting/bisect.pl: Add missing full stop M Porting/bisect.pl ----------------------------------------------------------------------- Summary of changes: Porting/bisect.pl | 2 +- op.c | 10 ++++++---- pod/perldelta.pod | 40 +++++++++++++++++++++++++++++++++++++++- t/op/anonsub.t | 7 +++++++ t/op/sub.t | 14 +++++++++++++- 5 files changed, 66 insertions(+), 7 deletions(-) diff --git a/Porting/bisect.pl b/Porting/bisect.pl index 81a7d9b..6a51f67 100755 --- a/Porting/bisect.pl +++ b/Porting/bisect.pl @@ -225,7 +225,7 @@ system 'git', 'bisect', 'run', $^X, $runner, @ARGV and die; END { my $end_time = time; - printf "That took %d seconds\n", $end_time - $start_time + printf "That took %d seconds.\n", $end_time - $start_time if defined $start_time; } diff --git a/op.c b/op.c index 70365f7..3e7f805 100644 --- a/op.c +++ b/op.c @@ -7712,12 +7712,14 @@ Perl_newATTRSUB_x(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, o ? (const GV *)cSVOPo->op_sv : NULL, ps, ps_len, ps_utf8); } - if (ps) { + if (!SvROK(gv)) { + if (ps) { sv_setpvn(MUTABLE_SV(gv), ps, ps_len); if ( ps_utf8 ) SvUTF8_on(MUTABLE_SV(gv)); - } - else + } + else sv_setiv(MUTABLE_SV(gv), -1); + } SvREFCNT_dec(PL_compcv); cv = PL_compcv = NULL; @@ -7767,7 +7769,7 @@ Perl_newATTRSUB_x(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, CvISXSUB_on(cv); } else { - GvCV_set(gv, NULL); + if (name) GvCV_set(gv, NULL); cv = newCONSTSUB_flags( NULL, name, namlen, name_is_utf8 ? SVf_UTF8 : 0, const_sv diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 5b12a91..df4466f 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -151,6 +151,9 @@ L<Pod::Perldoc> has been upgraded from version 3.23 to 3.24. L<constant> has been upgraded from version 1.31 to 1.32. +It now accepts fully-qualified constant names, allowing constants to be +defined in packages other than the caller. + =item * L<threads> has been upgraded from version 1.95 to 1.96. @@ -357,7 +360,9 @@ well. =item * -XXX +The parser no longer gets confused by C<\U=> within a double-quoted string. +It used to roduce a syntax error, but now compile it correctly. +[perl #80368] =back @@ -374,6 +379,39 @@ files in F<ext/> and F<lib/> are best summarized in L</Modules and Pragmata>. XXX +=item * + +Compile-time checking of constant dereferencing (e.g., +C<< my_constant->() >>) has been removed, since it was not taking +overloading into account. [perl #69456] [perl #122607] + +=item * + +Constant dereferencing now works correctly for typeglob constants. +Previously the glob was stringified and its name looked up. Now the glob +itself is used. [perl #69456] + +=item * + +When parsing a funny character ($ @ % &) followed by braces, the parser no +longer tries to guess whether it is a block or a hash constructor (causing +a syntax error when it guesses the latter), since it can only be a block. + +=item * + +C<undef $reference> now frees the referent immediately, instead of hanging +on to it until the next statement. [perl #122556] + +=item * + +Various cases where the name of a sub is used (autoload, overloading, error +messages) used to crash for lexical subs, but have been fixed. + +=item * + +Bareword lookup now tries to avoid vivifying packages if it turns out the +bareword is not going to be a subroutine name. + =back =head1 Known Problems diff --git a/t/op/anonsub.t b/t/op/anonsub.t index 6b8745f..ceb8d09 100644 --- a/t/op/anonsub.t +++ b/t/op/anonsub.t @@ -91,3 +91,10 @@ undef &{$x=sub{}}; $x->(); EXPECT Undefined subroutine called at - line 4. +######## +# NAME anon constant clobbering __ANON__ +sub __ANON__ { "42\n" } +print __ANON__; +sub(){3}; +EXPECT +42 diff --git a/t/op/sub.t b/t/op/sub.t index 1861623..575fa17 100644 --- a/t/op/sub.t +++ b/t/op/sub.t @@ -6,7 +6,7 @@ BEGIN { require './test.pl'; } -plan( tests => 34 ); +plan( tests => 37 ); sub empty_sub {} @@ -229,3 +229,15 @@ fresh_perl_is(<<'EOS', "", { stderr => 1 }, use strict; use warnings; eval q/use File::{Spec}/; eval q/use File::Spec/; EOS "check special blocks are cleared on error"); + +use constant { constant1 => 1, constant2 => 2 }; +{ + my $w; + local $SIG{__WARN__} = sub { $w++ }; + eval 'sub constant1; sub constant2($)'; + is eval '&constant1', '1', + 'stub re-declaration of constant with no prototype'; + is eval '&constant2', '2', + 'stub re-declaration of constant with wrong prototype'; + is $w, 2, 'two warnings from the above'; +} -- Perl5 Master Repository
