This cleans the "Can't localize lexical variable" error.
authorBrian Fraser <fraserbn@gmail.com>
Thu, 16 Jun 2011 10:57:22 +0000 (07:57 -0300)
committerFather Chrysostomos <sprout@cpan.org>
Wed, 13 Jul 2011 04:46:54 +0000 (21:46 -0700)
Plus the test case from t/run/fresh_perl.t, but in UTF-8,
in t/op/fresh_perl_utf8.t
That file currently has only that test, but I intend to
port others from fresh_perl.t to test clean stashes/GVs.

MANIFEST
op.c
t/op/fresh_perl_utf8.t [new file with mode: 0644]

index 9a12bb3..7f91488 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -4932,6 +4932,7 @@ t/op/filetest.t                   See if file tests work
 t/op/filetest_t.t              See if -t file test works
 t/op/flip.t                    See if range operator works
 t/op/fork.t                    See if fork works
+t/op/fresh_perl_utf8.t         UTF8 tests for pads and gvs
 t/op/getpid.t                  See if $$ and getppid work with threads
 t/op/getppid.t                 See if getppid works
 t/op/glob.t                    See if <*> works
diff --git a/op.c b/op.c
index d3734da..b073010 100644 (file)
--- a/op.c
+++ b/op.c
@@ -1665,8 +1665,8 @@ Perl_op_lvalue_flags(pTHX_ OP *o, I32 type, U32 flags)
     case OP_PADSV:
        PL_modcount++;
        if (!type) /* local() */
-           Perl_croak(aTHX_ "Can't localize lexical variable %s",
-                PAD_COMPNAME_PV(o->op_targ));
+           Perl_croak(aTHX_ "Can't localize lexical variable %"SVf,
+                PAD_COMPNAME_SV(o->op_targ));
        break;
 
     case OP_PUSHMARK:
diff --git a/t/op/fresh_perl_utf8.t b/t/op/fresh_perl_utf8.t
new file mode 100644 (file)
index 0000000..5439293
--- /dev/null
@@ -0,0 +1,19 @@
+#!./perl
+
+#This file is intentionally written in UTF-8
+
+BEGIN {
+    chdir 't' if -d 't';
+    @INC = '../lib';
+    require './test.pl';
+}
+
+use utf8;
+use strict;
+use open qw( :utf8 :std );
+
+{
+    local $@;
+    eval 'sub testme { my $ᨕ = "test"; { local $ᨕ = "new test"; print $ᨕ } }';
+    like( $@, qr/Can't localize lexical variable \$ᨕ at /u, q!"Can't localize lexical" error is in UTF-8! );
+}