summaryrefslogtreecommitdiff
path: root/mg.c
diff options
context:
space:
mode:
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;
}