summaryrefslogtreecommitdiff
path: root/dist/constant
diff options
context:
space:
mode:
authorZefram <zefram@fysh.org>2009-12-15 11:17:35 +0100
committerRafael Garcia-Suarez <rgs@consttype.org>2009-12-15 11:17:35 +0100
commit15dc519fb7cb1c4b51fbc196af8ecf273c534ad1 (patch)
treeab5b703617581872398019a7769c291cf9a3f2d2 /dist/constant
parent1443f10d16f26271d2df9b4bdda55dbe024319c3 (diff)
downloadperl-15dc519fb7cb1c4b51fbc196af8ecf273c534ad1.tar.gz
[perl #68640] Wrong error for undef constant name
Diffstat (limited to 'dist/constant')
-rw-r--r--dist/constant/lib/constant.pm11
-rw-r--r--dist/constant/t/constant.t8
2 files changed, 12 insertions, 7 deletions
diff --git a/dist/constant/lib/constant.pm b/dist/constant/lib/constant.pm
index a51ee7f277..3ee1a6f5b0 100644
--- a/dist/constant/lib/constant.pm
+++ b/dist/constant/lib/constant.pm
@@ -4,7 +4,7 @@ use strict;
use warnings::register;
use vars qw($VERSION %declared);
-$VERSION = '1.19';
+$VERSION = '1.20';
#=======================================================================
@@ -60,15 +60,14 @@ sub import {
}
$constants = shift;
} else {
- $constants->{+shift} = undef;
- }
-
- foreach my $name ( keys %$constants ) {
- unless (defined $name) {
+ unless (defined $_[0]) {
require Carp;
Carp::croak("Can't use undef as constant name");
}
+ $constants->{+shift} = undef;
+ }
+ foreach my $name ( keys %$constants ) {
# Normal constant name
if ($name =~ $normal_constant_name and !$forbidden{$name}) {
# Everything is okay
diff --git a/dist/constant/t/constant.t b/dist/constant/t/constant.t
index a42b7d2281..85a9355a19 100644
--- a/dist/constant/t/constant.t
+++ b/dist/constant/t/constant.t
@@ -9,7 +9,7 @@ END { @warnings && print STDERR join "\n- ", "accumulated warnings:", @warnings
use strict;
-use Test::More tests => 95;
+use Test::More tests => 96;
my $TB = Test::More->builder;
BEGIN { use_ok('constant'); }
@@ -341,3 +341,9 @@ $kloong = 'schlozhauer';
is ($@, '');
is_deeply (\@value, []);
}
+
+{
+ local $SIG{'__WARN__'} = sub { die "WARNING: $_[0]" };
+ eval 'use constant undef, 5; 1';
+ like $@, qr/\ACan't use undef as constant name at /;
+}