UV hint;
dSP;
- if (!SvOK(TOPs)) {
+ a_map_fetch(PL_op, &oi);
+
+ if (PL_op != oi.root && !SvOK(TOPs)) {
/* We always need to push an empty array to fool the pp_aelem() that comes
* later. */
SV *av;
RETURN;
}
- a_map_fetch(PL_op, &oi);
-
return CALL_FPTR(oi.old_pp)(aTHX);
}
a_map_fetch(PL_op, &oi);
- if (!SvOK(TOPs)) {
+ if (PL_op != oi.root && !SvOK(TOPs)) {
if (oi.root->op_flags & OPf_MOD) {
SV *hv;
POPs;
s{'%'}{'\@'};
print $array_t $_;
} else {
+ s!(\ba\b)?(\s*)HASH\b!($1 ? 'an': '') . "$2ARRAY"!eg;
s!->{([a-z])}!'->[' . num($1) . ']'!eg;
+ s!%(\{?)\$!\@$1\$!g;
my $buf;
my $suffix = $_;
my ($bracket, $prefix);
use strict;
use warnings;
-use Test::More tests => 6 * 3 * 260;
+use Test::More tests => 6 * 3 * 270;
use lib 't/lib';
use autovivification::TestCases;
$x->{a} = 1 # 1 for $x->{a}; () # '', undef, { a => 1 } # +store
$x->{a} = 1 # 1 for $x->{b}; () # '', undef, { a => 1, b => undef } # +store
+--- dereferencing ---
+
+$x # no warnings 'uninitialized'; my @a = %$x; () # ($strict ? qr/Can't use an undefined value as a HASH reference/ : ''), undef, undef
+$x # no warnings 'uninitialized'; my @a = %$x; () # ($strict ? qr/Can't use an undefined value as a HASH reference/ : ''), undef, undef #
+$x # no warnings 'uninitialized'; my @a = %$x; () # ($strict ? qr/Can't use an undefined value as a HASH reference/ : ''), undef, undef # +fetch
+$x # no warnings 'uninitialized'; my @a = %$x; () # ($strict ? qr/Can't use an undefined value as a HASH reference/ : ''), undef, undef # +exists
+$x # no warnings 'uninitialized'; my @a = %$x; () # ($strict ? qr/Can't use an undefined value as a HASH reference/ : ''), undef, undef # +delete
+$x # no warnings 'uninitialized'; my @a = %$x; () # ($strict ? qr/Can't use an undefined value as a HASH reference/ : ''), undef, undef # +store
+
+$x->{a} = 1 # my @a = %$x; () # '', undef, { a => 1 } # +fetch
+$x->{a} = 1 # my @a = %$x; () # '', undef, { a => 1 } # +exists
+$x->{a} = 1 # my @a = %$x; () # '', undef, { a => 1 } # +delete
+$x->{a} = 1 # my @a = %$x; () # '', undef, { a => 1 } # +store
+
--- exists ---
$x # exists $x->{a} # '', '', { }
use strict;
use warnings;
-use Test::More tests => 6 * 3 * 260;
+use Test::More tests => 6 * 3 * 270;
use lib 't/lib';
use autovivification::TestCases;
$x->[0] = 1 # 1 for $x->[0]; () # '', undef, [ 1 ] # +store
$x->[0] = 1 # 1 for $x->[1]; () # '', undef, [ 1, undef ] # +store
+--- dereferencing ---
+
+$x # no warnings 'uninitialized'; my @a = @$x; () # ($strict ? qr/Can't use an undefined value as an ARRAY reference/ : ''), undef, undef
+$x # no warnings 'uninitialized'; my @a = @$x; () # ($strict ? qr/Can't use an undefined value as an ARRAY reference/ : ''), undef, undef #
+$x # no warnings 'uninitialized'; my @a = @$x; () # ($strict ? qr/Can't use an undefined value as an ARRAY reference/ : ''), undef, undef # +fetch
+$x # no warnings 'uninitialized'; my @a = @$x; () # ($strict ? qr/Can't use an undefined value as an ARRAY reference/ : ''), undef, undef # +exists
+$x # no warnings 'uninitialized'; my @a = @$x; () # ($strict ? qr/Can't use an undefined value as an ARRAY reference/ : ''), undef, undef # +delete
+$x # no warnings 'uninitialized'; my @a = @$x; () # ($strict ? qr/Can't use an undefined value as an ARRAY reference/ : ''), undef, undef # +store
+
+$x->[0] = 1 # my @a = @$x; () # '', undef, [ 1 ] # +fetch
+$x->[0] = 1 # my @a = @$x; () # '', undef, [ 1 ] # +exists
+$x->[0] = 1 # my @a = @$x; () # '', undef, [ 1 ] # +delete
+$x->[0] = 1 # my @a = @$x; () # '', undef, [ 1 ] # +store
+
--- exists ---
$x # exists $x->[0] # '', '', [ ]
*{caller().'::testcase_ok'} = \&testcase_ok;
}
+sub in_strict { (caller 0)[8] & (eval { strict::bits(@_) } || 0) };
+
sub source {
my ($var, $init, $code, $exp, $use, $global) = @_;
my $decl = $global ? "our $var; local $var;" : "my $var;";
my $test = $var =~ /^[@%]/ ? "\\$var" : $var;
return <<TESTCASE;
-my \@exp = ($exp);
$decl
$init
+my \$strict = autovivification::TestCases::in_strict('refs');
+my \@exp = ($exp);
my \$res = eval {
local \$SIG{__WARN__} = sub { die join '', 'warn:', \@_ };
$use