summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Brine <ikegami@adaelis.com>2010-07-13 12:56:38 -0700
committerRafael Garcia-Suarez <rgs@consttype.org>2010-08-13 13:36:29 +0200
commit213f7ada530c1a4c4148622ba78577585f8ab9d0 (patch)
tree144b529bc5927bd2b3fe75be5791a6c6ed22fbaa
parente2fe06dd0f4d62a54d7bbc2a1f42dae0dd6bf19e (diff)
downloadperl-213f7ada530c1a4c4148622ba78577585f8ab9d0.tar.gz
Pure Perl lvalue subs can't return temps, even if they are magical. This holds back a fix for RT#67838.
This commit allows PP lvalue subs to return temps with set magic and removes TODO from tests.
-rw-r--r--ext/XS-APItest/t/temp_lv_sub.t1
-rw-r--r--pp_hot.c6
2 files changed, 3 insertions, 4 deletions
diff --git a/ext/XS-APItest/t/temp_lv_sub.t b/ext/XS-APItest/t/temp_lv_sub.t
index bfcacd60df..d0c51fde75 100644
--- a/ext/XS-APItest/t/temp_lv_sub.t
+++ b/ext/XS-APItest/t/temp_lv_sub.t
@@ -27,7 +27,6 @@ sub make_temp_mg_lv :lvalue { XS::APItest::TempLv::make_temp_mg_lv($_[0]); }
}
{
- local $TODO = "PP lvalue sub can't return magical temp";
my $x = "{}";
eval { make_temp_mg_lv($x) = "b"; };
is($@, '', 'temp mg lv from pp exception check');
diff --git a/pp_hot.c b/pp_hot.c
index 2b67f4f23a..e1f0fc9904 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -2610,13 +2610,13 @@ PP(pp_leavesublv)
MARK = newsp + 1;
EXTEND_MORTAL(1);
if (MARK == SP) {
- /* Temporaries are bad unless they happen to be elements
- * of a tied hash or array */
+ /* Temporaries are bad unless they happen to have set magic
+ * attached, such as the elements of a tied hash or array */
if ((SvFLAGS(TOPs) & (SVs_TEMP | SVs_PADTMP) ||
(SvFLAGS(TOPs) & (SVf_READONLY | SVf_FAKE))
== SVf_READONLY
) &&
- !(SvRMAGICAL(TOPs) && mg_find(TOPs, PERL_MAGIC_tiedelem))) {
+ !SvSMAGICAL(TOPs)) {
LEAVE;
cxstack_ix--;
POPSUB(cx,sv);