diff options
author | Father Chrysostomos <sprout@cpan.org> | 2014-09-24 13:22:49 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2014-10-10 21:56:33 -0700 |
commit | 26a50d995a0122ec4aec3392722aa70e74fe54f3 (patch) | |
tree | a5f3f4a608bf9c774cdd3efcb31c3cdc0e0f5bf3 /mg.c | |
parent | e5e1ee61c50f938a3a8b7487d29d5128d4f9a909 (diff) | |
download | perl-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.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -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; } |