$ ./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.
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;
}
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[]} ;