diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-08-21 22:14:55 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-08-21 22:45:43 -0700 |
commit | 99fc7eca408edfc467a15a24adff8b2fd5a7705c (patch) | |
tree | 2ced4fd5134a8d9f6dc878e778df5b70070a5b91 /pp.c | |
parent | f8326b3e75b86d985f87404e11ed018bc037a3af (diff) | |
download | perl-99fc7eca408edfc467a15a24adff8b2fd5a7705c.tar.gz |
Make rv2gv return autovivified magic GVs
There is special code in pp_rv2gv to deal with the case of built-in
variables that are created on the fly. It basically pretends that
they have always existed, even in rvalue context.
Normally, defined(*{"foo"}) will not actually create the *foo glob,
but will simply return false. defined(*{">"}), however is supposed
to return true because of the $> variable; its popping into existing
when looked at being an implementation detail. That is the whole pur-
pose of is_gv_magical_sv in gv.c.
Prior to this commit, however, defined(*{">"}) would autovivify the
GV, but then return *false*!
It was simply a matter of faulty logic in this part of pp_rv2gv:
SV * const temp = MUTABLE_SV(gv_fetchsv(sv, 0, SVt_PVGV));
if (!temp
&& (!is_gv_magical_sv(sv,0)
|| !(sv = MUTABLE_SV(gv_fetchsv(sv, GV_ADD,
SVt_PVGV))))) {
RETSETUNDEF;
}
sv = temp;
The autovivification happens in the second gv_fetchsv call. But after
the new GV is assigned to sv and the condition proves false, we reach
the sv = temp assignment which clobbers it.
Diffstat (limited to 'pp.c')
-rw-r--r-- | pp.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -207,7 +207,7 @@ PP(pp_rv2gv) SVt_PVGV))))) { RETSETUNDEF; } - sv = temp; + if (temp) sv = temp; } else { if (PL_op->op_private & HINT_STRICT_REFS) |