In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/10030f4b9e57e68d03a6b1eb1a9bed9fb389e8ac?hp=fc273927378ed6a1a60a5758f7e36713630d5e13>
- Log ----------------------------------------------------------------- commit 10030f4b9e57e68d03a6b1eb1a9bed9fb389e8ac Author: Father Chrysostomos <spr...@cpan.org> Date: Sat Jul 30 23:51:29 2016 -0700 Donât trigger warnings for qq"@builtin" Built-in arrays should not be giving warnings about possible unin- tended interpolation (which happens with nonexistent arrays). Some built-in variables do not exist if they are not needed, but perl will generally pretend that they did already exist whenever they are fetched. It is such variables that trigger this warning erroneously: $ ./miniperl -we 'sub dump_isa { warn "@ISA" } @ISA = ("foo","bar"); dump_isa' Possible unintended interpolation of @ISA in string at -e line 1. foo bar at -e line 1. I discovered this when writing a test for @DB::args, using -w. warnings.pm uses @DB::args, so âuse warningsâ code wonât get the warn- ing, but code using -w gets it: $ ./miniperl -we 'sub foo { package DB { () = caller 0 } print "@DB::args\n" } foo(1..3);' Possible unintended interpolation of @DB::args in string at -e line 1. 1 2 3 The code in toke.c that decides whether this warning should take place needs to supply the GV_ADDMG flag to gv_fetchpvn_flags, making it one of the code paths that engages in the pretence mentioned above. That code already had an explicit exception for @+ and @-. This com- mit removes it as being no longer necessary. M t/lib/warnings/toke M toke.c commit aebe74f4cf6c4b5d292a30ff3da053b73c26477a Author: Father Chrysostomos <spr...@cpan.org> Date: Sat Jul 30 23:19:11 2016 -0700 t/lib/common.pl: Ignore editor droppings This bites me all the time. M t/lib/common.pl commit 7bb33634741e6401456a85c49eb51fe0fc1aefc7 Author: Father Chrysostomos <spr...@cpan.org> Date: Sat Jul 30 19:37:04 2016 -0700 Exempt @DB::args from âused onceâ warnings A perfectly benign use of @DB::args like sub foo { package DB { () = caller 0 } print "@DB::args\n" } foo(1..3); warns under -w, though that is exactly its intended use. That is is not nice. warnings.pm itself uses @DB::args, which is why this went unnoticed for so many years. This commit eliminates the âused onceâ warning, but the âPossible unintended interpolationâ message that that code produces will be handled in another commit. M gv.c M t/lib/warnings/perl ----------------------------------------------------------------------- Summary of changes: gv.c | 4 ++++ t/lib/common.pl | 2 +- t/lib/warnings/perl | 14 ++++++++++++++ t/lib/warnings/toke | 5 +++++ toke.c | 6 ++---- 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/gv.c b/gv.c index 46eb079..4ea0917 100644 --- a/gv.c +++ b/gv.c @@ -1831,6 +1831,10 @@ S_gv_magicalize(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len, GvMULTI_on(gv); break; case 'a': + if (stash == PL_debstash && len==4 && strEQ(name2,"rgs")) { + GvMULTI_on(gv_AVadd(gv)); + break; + } case 'b': if (len == 1 && sv_type == SVt_PV) GvMULTI_on(gv); diff --git a/t/lib/common.pl b/t/lib/common.pl index 4ff2b09..561e1ff 100644 --- a/t/lib/common.pl +++ b/t/lib/common.pl @@ -27,7 +27,7 @@ if (@ARGV) { print "ARGV = [@ARGV]\n"; @w_files = map { "./lib/$pragma_name/$_" } @ARGV; } else { - @w_files = sort grep !/\.rej\z/, + @w_files = sort grep !/( \.rej | ~ | \ \(Autosaved\)\.txt ) \z/nx, glob catfile(curdir(), "lib", $pragma_name, "*"); } diff --git a/t/lib/warnings/perl b/t/lib/warnings/perl index e5acc6c..9a30f60 100644 --- a/t/lib/warnings/perl +++ b/t/lib/warnings/perl @@ -47,6 +47,20 @@ $0; # and $123; # numbers $_; # and $_foo; # underscores (none of which should warn) +@DB::args +EXPECT +######## +-w +# perl.c +print # avoid void warning +$\, # test a few +$:, # punct vars +$0, # and +$123, # numbers +$_, # and +$_foo, # underscores (none of which should warn) +@DB::args +if 0; EXPECT ######## -W diff --git a/t/lib/warnings/toke b/t/lib/warnings/toke index 0b23fe5..10f20f9 100644 --- a/t/lib/warnings/toke +++ b/t/lib/warnings/toke @@ -1112,6 +1112,11 @@ no warnings 'ambiguous'; EXPECT Possible unintended interpolation of @mjd_previously_unused_ãrrãy in string at - line 5. ######## +-w +# toke.c +$_ = "@DB::args"; +EXPECT +######## # toke.c # 20020328 mjd-perl-pat...@plover.com at behest of jfri...@yahoo.com use warnings 'regexp'; diff --git a/toke.c b/toke.c index 70449ca..288a630 100644 --- a/toke.c +++ b/toke.c @@ -8581,11 +8581,9 @@ S_pending_ident(pTHX) && !PL_lex_brackets) { GV *const gv = gv_fetchpvn_flags(PL_tokenbuf + 1, tokenbuf_len - 1, - ( UTF ? SVf_UTF8 : 0 ), SVt_PVAV); + ( UTF ? SVf_UTF8 : 0 ) | GV_ADDMG, + SVt_PVAV); if ((!gv || ((PL_tokenbuf[0] == '@') ? !GvAV(gv) : !GvHV(gv))) - /* DO NOT warn for @- and @+ */ - && !( PL_tokenbuf[2] == '\0' - && ( PL_tokenbuf[1] == '-' || PL_tokenbuf[1] == '+' )) ) { /* Downgraded from fatal to warning 20000522 mjd */ -- Perl5 Master Repository