This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pp_hot.c: Make warnings utf8-clean
authorBrian Fraser <fraserbn@gmail.com>
Wed, 6 Jul 2011 16:45:07 +0000 (13:45 -0300)
committerFather Chrysostomos <sprout@cpan.org>
Thu, 6 Oct 2011 20:01:12 +0000 (13:01 -0700)
pp_hot.c
t/lib/strict/refs
t/uni/method.t

index 5926874..aaff28f 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -2587,7 +2587,7 @@ PP(pp_entersub)
            if (!sym)
                DIE(aTHX_ PL_no_usym, "a subroutine");
            if (PL_op->op_private & HINT_STRICT_REFS)
-               DIE(aTHX_ "Can't use string (\"%.32s\"%s) as a subroutine ref while \"strict refs\" in use", sym, len>32 ? "..." : "");
+               DIE(aTHX_ "Can't use string (\"%" SVf32 "\"%s) as a subroutine ref while \"strict refs\" in use", sv, len>32 ? "..." : "");
            cv = get_cvn_flags(sym, len, GV_ADD|SvUTF8(sv));
            break;
        }
@@ -3006,10 +3006,10 @@ S_method_common(pTHX_ SV* meth, U32* hashp)
                     && (ob = MUTABLE_SV(GvIO((const GV *)ob)))
                     && SvOBJECT(ob))))
     {
-       const char * const name = SvPV_nolen_const(meth);
-       Perl_croak(aTHX_ "Can't call method \"%s\" on unblessed reference",
-                  (SvSCREAM(meth) && strEQ(name,"isa")) ? "DOES" :
-                  name);
+       Perl_croak(aTHX_ "Can't call method \"%"SVf"\" on unblessed reference",
+                  SVfARG((SvSCREAM(meth) && strEQ(SvPV_nolen_const(meth),"isa"))
+                                        ? newSVpvs_flags("DOES", SVs_TEMP)
+                                        : meth));
     }
 
     stash = SvSTASH(ob);
index 36b36f1..09b962f 100644 (file)
@@ -338,3 +338,11 @@ use strict 'refs';
 my $o = 1 ; $o->{1} ;
 EXPECT
 Can't use string ("1") as a HASH ref while "strict refs" in use at - line 3.
+########
+# pp_hot.c [pp_entersub]
+use strict 'refs';
+use utf8;
+use open qw( :utf8 :std );
+&{"F"};
+EXPECT
+Can't use string ("F") as a subroutine ref while "strict refs" in use at - line 5.
index fdefbf5..5009a1c 100644 (file)
@@ -15,7 +15,7 @@ use utf8;
 use open qw( :utf8 :std );
 no warnings 'once';
 
-plan(tests => 15);
+plan(tests => 16);
 
 #Can't use bless yet, as it might not be clean
 
@@ -38,3 +38,5 @@ is(F->${\"b"}, "UTF8 Stash&meth", '..as does for ->${\""}');
 eval { F->${\"b\0nul"} };
 ok $@, "Even if both stash and method are in UTF-8, lookup is nul-clean";
 
+eval { my $ref = \my $var; $ref->method };
+like $@, qr/Can't call method "method" on unblessed reference /u;