summaryrefslogtreecommitdiff
path: root/t/lib/strict
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-05-25 22:44:39 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-06-07 08:18:53 -0700
commitbf3d870f8b8accd379ab520c1ff1daa10317d27d (patch)
tree5146803b0bf1ed8f28a35e8c6728b09f1ab2710a /t/lib/strict
parentf90b723246c15bceccd726b73c412184c27eca7d (diff)
downloadperl-bf3d870f8b8accd379ab520c1ff1daa10317d27d.tar.gz
Make strict refs report $1 the same way as "$1"
A magical variable is never SvPOK, but only SvPOKp. The code that determined whether to put an ellipsis mark after a truncated symbol name was only checking SvPOK, resulting in this discrepancy: $ perl5.15.9 -e 'use strict; *{"a"x40}' Can't use string ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"...) as a symbol ref while "strict refs" in use at -e line 1. $ perl5.15.9 -e 'use strict; ("a"x40)=~/(.*)/; *{$1}' Can't use string ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as a symbol ref while "strict refs" in use at -e line 1. $ perl5.15.9 -e 'use strict; ${"a"x40}' Can't use string ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"...) as a SCALAR ref while "strict refs" in use at -e line 1. $ perl5.15.9 -e 'use strict; ("a"x40)=~/(.*)/; ${$1}' Can't use string ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as a SCALAR ref while "strict refs" in use at -e line 1. SvPOK variables are also SvPOKp, so checking just the latter suffices.
Diffstat (limited to 't/lib/strict')
-rw-r--r--t/lib/strict/refs23
1 files changed, 23 insertions, 0 deletions
diff --git a/t/lib/strict/refs b/t/lib/strict/refs
index d9bff7cd84..21dbfcfab6 100644
--- a/t/lib/strict/refs
+++ b/t/lib/strict/refs
@@ -27,6 +27,29 @@ Can't use string ("A::Really::Big::Package::Name::T"...) as a HASH ref while "st
# strict refs - error
use strict ;
+"A::Really::Big::Package::Name::To::Use" =~ /(.*)/;
+${$1};
+EXPECT
+Can't use string ("A::Really::Big::Package::Name::T"...) as a SCALAR ref while "strict refs" in use at - line 5.
+########
+
+# strict refs - error
+use strict ;
+*{"A::Really::Big::Package::Name::To::Use"; }
+EXPECT
+Can't use string ("A::Really::Big::Package::Name::T"...) as a symbol ref while "strict refs" in use at - line 4.
+########
+
+# strict refs - error
+use strict ;
+"A::Really::Big::Package::Name::To::Use" =~ /(.*)/;
+*{$1}
+EXPECT
+Can't use string ("A::Really::Big::Package::Name::T"...) as a symbol ref while "strict refs" in use at - line 5.
+########
+
+# strict refs - error
+use strict ;
my $fred ;
my $a = ${"fred"} ;
EXPECT