The original fix for tied elements losing magic had a bug that was masked
by a bool casting issue. Once the casting was fixed, the bug surfaced:
elements of @+ lost their values when returned from a sub. By removing the
TEMP flag from the regdatum PVLV, we force it to be copied when returned.
sv = sv_newmortal();
sv_upgrade(sv, SVt_PVLV);
mg_copy(MUTABLE_SV(av), sv, 0, key);
+ if (!tied_magic) /* for regdata, force leavesub to make copies */
+ SvTEMP_off(sv);
LvTYPE(sv) = 't';
LvTARG(sv) = sv; /* fake (SV**) */
return &(LvTARG(sv));
# Test for bug [perl #27839]
{
- local $TODO = "fixing a casting issue revealed broken behaviour in this test";
my $x;
sub f {
"abc" =~ /(.)./;
$x = "@+";
return @+;
};
+ "pqrstuvwxyz" =~ /..(....)../; # prime @+ etc in this scope
my @y = f();
is $x, "@y", "return a magic array ($x) vs (@y)";