handle magic in multideref "unit val" var names
[perl #128253] Assert fail in S_find_uninit_var
$ perl5240 -we'$ISA[0][0]'
Useless use of array element in void context at -e line 1.
perl5240: sv.c:16078: S_find_uninit_var: Assertion `is_hv' failed.
The code in find_uninit_var() which looks for a variable name associated
with an uninitialized value assumed, in the OP_MULTIDEREF branch, that the
value was either an index if the op was top-level ($foo[$uninit]), or an
array/hash element otherwise (1+$foo[...]).
It turns out here's a third possibility: magic. In $ISA[0][0], the first
array lookup is in lval context, so it initially autovivifies to undef.
Normally it would shortly afterwards be upgraded to a ref to an empty AV,
but first ISA set magic for @ISA is invoked. This ends up scanning @ISA
and finds an uninit value which it tries to use as a key into the stash
cache, triggering an ununit value warning.
This commit expands the OP_MULTIDEREF code in find_uninit_var() to handle
this third possibility - chiefly by not returning a variable name unless
the index var is the same SV as the uninit value. As well as fixing the
assert failure in this ticket, it also stops printing an incorrect index in
code like this:
$ perl -we'my $i = 0; $ISA[$i] = 1'
before:
....
Use of uninitialized value $i in array element at -e line 1.
Use of uninitialized value $i in array element at -e line 1.
Recursive inheritance detected in package 'main' at -e line 1.
after:
....
Use of uninitialized value in array element at -e line 1.
Use of uninitialized value in array element at -e line 1.
Recursive inheritance detected in package 'main' at -e line 1.
@ISA magic still has recursion issues with undef values, as can be seen
above. I don't address those issues here. Because of that, I haven't
been able to add tests.