[perl #97980] Stop tied() from returning a copy

Now tied() returns the actual scalar used to hold the tie object,
so one can write weaken(tied $foo).
This commit is contained in:
Father Chrysostomos 2011-11-26 18:17:45 -08:00
parent 98be996420
commit dc456155af
2 changed files with 9 additions and 4 deletions

View File

@ -973,10 +973,7 @@ PP(pp_tied)
RETPUSHUNDEF;
if ((mg = SvTIED_mg(sv, how))) {
SV *osv = SvTIED_obj(sv, mg);
if (osv == mg->mg_obj)
osv = sv_mortalcopy(osv);
PUSHs(osv);
PUSHs(SvTIED_obj(sv, mg));
RETURN;
}
RETPUSHUNDEF;

View File

@ -1180,3 +1180,11 @@ fetching
before at - line 8.
fetching
after at - line 10.
########
# tied returns same value as tie
sub TIESCALAR{bless[]}
$tyre = \tie $tied, "";
print "ok\n" if \tied $tied == $tyre;
EXPECT
ok