From 5ede95a04d0e1d9b9bf9b5b82cd634b54bf90dc3 Mon Sep 17 00:00:00 2001 From: Brian Fraser Date: Thu, 16 Jun 2011 07:57:22 -0300 Subject: [PATCH] This cleans the "Can't localize lexical variable" error. 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 | 1 + op.c | 4 ++-- t/op/fresh_perl_utf8.t | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 t/op/fresh_perl_utf8.t diff --git a/MANIFEST b/MANIFEST index 9a12bb3..7f91488 100644 --- 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 --- 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 index 0000000..5439293 --- /dev/null +++ b/t/op/fresh_perl_utf8.t @@ -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! ); +} -- 2.7.4