In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/614f2ce4f49414577dec90f8c9bd3f0404bf2ebf?hp=81b96c32839f3fa3ae70bddf441b4e6827eb93c8>
- Log ----------------------------------------------------------------- commit 614f2ce4f49414577dec90f8c9bd3f0404bf2ebf Author: David Mitchell <[email protected]> Date: Wed Sep 28 13:40:34 2016 +0100 undef $0 shouldn't warn about $0 RT #123910 $ perl -we'undef $0' Use of uninitialized value $0 in undef operator at -e line 1. Generally, undef should ignore its arg when determining which var was undef: only magic will trigger an undef warning. ----------------------------------------------------------------------- Summary of changes: sv.c | 6 +++++- t/lib/warnings/9uninit | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/sv.c b/sv.c index 088359f..dd0b3d4 100644 --- a/sv.c +++ b/sv.c @@ -15823,6 +15823,11 @@ S_find_uninit_var(pTHX_ const OP *const obase, const SV *const uninit_sv, switch (obase->op_type) { + case OP_UNDEF: + /* undef should care if its args are undef - any warnings + * will be from tied/magic vars */ + break; + case OP_RV2AV: case OP_RV2HV: case OP_PADAV: @@ -16369,7 +16374,6 @@ S_find_uninit_var(pTHX_ const OP *const obase, const SV *const uninit_sv, case OP_ALARM: case OP_SEMGET: case OP_GETLOGIN: - case OP_UNDEF: case OP_SUBSTR: case OP_AEACH: case OP_EACH: diff --git a/t/lib/warnings/9uninit b/t/lib/warnings/9uninit index 5171941..b8fd925 100644 --- a/t/lib/warnings/9uninit +++ b/t/lib/warnings/9uninit @@ -2186,3 +2186,11 @@ use warnings 'uninitialized'; my $x = "" . open my $fh, "<", "no / such / file"; EXPECT Use of uninitialized value in concatenation (.) or string at - line 3. +######## +# RT #123910 +# undef's arg being undef doesn't trigger warnings - any warning will be +# from tied/magic vars +use warnings 'uninitialized'; +undef $0; +EXPECT +Use of uninitialized value in undef operator at - line 5. -- Perl5 Master Repository
