@INC = '../lib';
require './test.pl';
}
-plan tests=>151;
+plan tests=>156;
sub a : lvalue { my $a = 34; ${\(bless \$a)} } # Return a temporary
sub b : lvalue { ${\shift} }
}
is("@p", "1 8");
+sub keeze : lvalue { keys %__ }
+%__ = ("a","b");
+keeze = 64;
+is scalar %__, '1/64', 'keys assignment through lvalue sub';
+
# Bug 20001223.002: split thought that the list had only one element
@ary = qw(4 5 6);
sub lval1 : lvalue { $ary[0]; }
continue { $suffix = ' (explicit return)' }
# autovivification
+$suffix = '';
for my $sub (sub :lvalue {$_}, sub :lvalue {return $_}) {
undef $_;
&$sub()->[3] = 4;
is join('-',%$_), '4-5', '%{func()} autovivification'.$suffix;
}
continue { $suffix = ' (explicit return)' }
+
+# [perl #92406] [perl #92290] Returning a pad var in rvalue context
+$suffix = '';
+for my $sub (
+ sub :lvalue { my $x = 72; $x },
+ sub :lvalue { my $x = 72; return $x }
+) {
+ is scalar(&$sub), 72, "sub returning pad var in scalar context$suffix";
+ is +(&$sub)[0], 72, "sub returning pad var in list context$suffix";
+}
+continue { $suffix = ' (explicit return)' }