summaryrefslogtreecommitdiff
path: root/mg.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-09-25 08:19:13 -0700
committerFather Chrysostomos <sprout@cpan.org>2014-10-10 21:56:35 -0700
commitc146a62a4cab49a74d6cee4acf18e3ec9b40ee60 (patch)
tree24bcd3deeff2392e103f8baa58655d1312c3a6aa /mg.c
parentb7ae253e76cba86199de07716b73ab1238d0b134 (diff)
downloadperl-c146a62a4cab49a74d6cee4acf18e3ec9b40ee60.tar.gz
List assignment to lexical scalar refs
\($x,$y)=... does not work yet, but \(my $x) and (\$x, \$y) do.
Diffstat (limited to 'mg.c')
-rw-r--r--mg.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/mg.c b/mg.c
index 2284783625..ff5e47c3e3 100644
--- a/mg.c
+++ b/mg.c
@@ -2469,9 +2469,18 @@ Perl_magic_setlvref(pTHX_ SV *sv, MAGIC *mg)
if (SvTYPE(SvRV(sv)) > SVt_PVLV)
/* diag_listed_as: Assigned value is not %s reference */
Perl_croak(aTHX_ "Assigned value is not a SCALAR reference");
- assert(isGV(mg->mg_obj));
- gv_setref(mg->mg_obj, sv);
- SvSETMAGIC(mg->mg_obj);
+ switch (mg->mg_obj ? SvTYPE(mg->mg_obj) : 0) {
+ case 0:
+ {
+ SV * const old = PAD_SV(mg->mg_len);
+ PAD_SETSV(mg->mg_len, SvREFCNT_inc_NN(SvRV(sv)));
+ SvREFCNT_dec(old);
+ break;
+ }
+ case SVt_PVGV:
+ gv_setref(mg->mg_obj, sv);
+ SvSETMAGIC(mg->mg_obj);
+ }
sv_unmagic(sv, PERL_MAGIC_lvref);
return 0;
}