summaryrefslogtreecommitdiff
path: root/mg.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-09-24 13:22:49 -0700
committerFather Chrysostomos <sprout@cpan.org>2014-10-10 21:56:33 -0700
commit26a50d995a0122ec4aec3392722aa70e74fe54f3 (patch)
treea5f3f4a608bf9c774cdd3efcb31c3cdc0e0f5bf3 /mg.c
parente5e1ee61c50f938a3a8b7487d29d5128d4f9a909 (diff)
downloadperl-26a50d995a0122ec4aec3392722aa70e74fe54f3.tar.gz
List assignment to package scalar ref
\ on the lhs returns a special magical scalar with set-magic that does the aliasing. I considered having a separate abind op that would be like aassign, but different. However, I realised that for ($x, \$y) = ... to work it would have to duplicate all of aassign. So I went with the sim- pler magic implementation.
Diffstat (limited to 'mg.c')
-rw-r--r--mg.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/mg.c b/mg.c
index e271f883b2..2284783625 100644
--- a/mg.c
+++ b/mg.c
@@ -2465,7 +2465,14 @@ int
Perl_magic_setlvref(pTHX_ SV *sv, MAGIC *mg)
{
PERL_ARGS_ASSERT_MAGIC_SETLVREF;
- Perl_croak(aTHX_ "Unimplemented");
+ if (!SvROK(sv)) Perl_croak(aTHX_ "Assigned value is not a reference");
+ 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);
+ sv_unmagic(sv, PERL_MAGIC_lvref);
return 0;
}