Exempt @DB::args from ‘used once’ warnings
authorFather Chrysostomos <[email protected]>
Sun, 31 Jul 2016 02:37:04 +0000 (19:37 -0700)
committerFather Chrysostomos <[email protected]>
Sun, 31 Jul 2016 13:35:04 +0000 (06:35 -0700)
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.

gv.c
t/lib/warnings/perl

index 46eb079..4ea0917 100644 (file)
--- 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);
index e5acc6c..9a30f60 100644 (file)
@@ -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