diff options
author | Father Chrysostomos <sprout@cpan.org> | 2014-09-25 08:19:13 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2014-10-10 21:56:35 -0700 |
commit | c146a62a4cab49a74d6cee4acf18e3ec9b40ee60 (patch) | |
tree | 24bcd3deeff2392e103f8baa58655d1312c3a6aa /mg.c | |
parent | b7ae253e76cba86199de07716b73ab1238d0b134 (diff) | |
download | perl-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.c | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -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; } |