diff options
author | Father Chrysostomos <sprout@cpan.org> | 2010-12-10 14:54:13 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2010-12-10 16:09:32 -0800 |
commit | 6d1f0892ce0bd77f843552ab189aa5f121c374d4 (patch) | |
tree | 94a3bfc018033cdfc63ddd2519c51063f9498333 | |
parent | 98be99db6ff47327a7754b282e66c6be7eb35bb6 (diff) | |
download | perl-6d1f0892ce0bd77f843552ab189aa5f121c374d4.tar.gz |
[perl #72090] unitialized variable name wrong with no strict refs
$ ./perl -we '$a = @$a > 0'
Use of uninitialized value $a in array dereference at -e line 1.
Use of uninitialized value $a in numeric gt (>) at -e line 1.
S_find_uninit_var was not taking into account that rv2*v could return
undef. So it merrily looked at the child ops to find one that named
a variable.
This commit makes it skip any rv2av/rv2hv that does not have an OP_GV
as its child op.
In other words, it skips @{...} and %{...} (including the shorthand
forms @$foo and %$foo), but not @foo or %foo.
-rw-r--r-- | sv.c | 6 | ||||
-rw-r--r-- | t/lib/warnings/sv | 7 |
2 files changed, 13 insertions, 0 deletions
@@ -14031,6 +14031,12 @@ S_find_uninit_var(pTHX_ const OP *const obase, const SV *const uninit_sv, if ( (type == OP_CONST && SvOK(cSVOPx_sv(kid))) || (type == OP_NULL && ! (kid->op_flags & OPf_KIDS)) || (type == OP_PUSHMARK) + || ( + /* @$a and %$a, but not @a or %a */ + (type == OP_RV2AV || type == OP_RV2HV) + && cUNOPx(kid)->op_first + && cUNOPx(kid)->op_first->op_type != OP_GV + ) ) continue; } diff --git a/t/lib/warnings/sv b/t/lib/warnings/sv index dbab90bf48..e29553a97b 100644 --- a/t/lib/warnings/sv +++ b/t/lib/warnings/sv @@ -209,6 +209,13 @@ Use of uninitialized value $a in join or string at - line 4. Use of uninitialized value $a in concatenation (.) or string at - line 5. Use of uninitialized value $a in concatenation (.) or string at - line 6. ######## +# [perl #72090] +use warnings 'uninitialized'; +$a = @$a > 0; +EXPECT +Use of uninitialized value $a in array dereference at - line 3. +Use of uninitialized value in numeric gt (>) at - line 3. +######## # sv.c use warnings 'numeric' ; sub TIESCALAR{bless[]} ; |