There is no reason tied (or otherwise magical variables like $/)
should be exempt from the ‘Attempt to bless into a reference’ error.
t/lib/Count.pm Helper for t/op/method.t
t/lib/croak/mg Test croak calls from mg.c
t/lib/croak/op Test croak calls from op.c
+t/lib/croak/pp Test croak calls from pp.c
t/lib/croak/pp_ctl Test croak calls from pp_ctl.c
t/lib/croak/pp_hot Test croak calls from pp_hot.c
t/lib/croak.t Test calls to Perl_croak() in the C source.
const char *ptr;
if (!ssv) goto curstash;
- if (!SvGMAGICAL(ssv) && !SvAMAGIC(ssv) && SvROK(ssv))
+ SvGETMAGIC(ssv);
+ if (!SvAMAGIC(ssv) && SvROK(ssv))
Perl_croak(aTHX_ "Attempt to bless into a reference");
- ptr = SvPV_const(ssv,len);
+ ptr = SvPV_nomg_const(ssv,len);
if (len == 0)
Perl_ck_warner(aTHX_ packWARN(WARN_MISC),
"Explicit blessing to '' (assuming package main)");
--- /dev/null
+__END__
+# NAME [perl #119809] Attempt to bless into a reference (tied)
+sub TIESCALAR { bless [] }
+sub FETCH { [] }
+tie $t, "";
+bless({}, $t);
+EXPECT
+Attempt to bless into a reference at - line 4.
+########
+# NAME [perl #119809] Attempt to bless into a reference (magical)
+$/ = \1;
+bless [], $/
+EXPECT
+Attempt to bless into a reference at - line 2.