In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/15dc519fb7cb1c4b51fbc196af8ecf273c534ad1?hp=1443f10d16f26271d2df9b4bdda55dbe024319c3>

- Log -----------------------------------------------------------------
commit 15dc519fb7cb1c4b51fbc196af8ecf273c534ad1
Author: Zefram <zef...@fysh.org>
Date:   Tue Dec 15 11:17:35 2009 +0100

    [perl #68640] Wrong error for undef constant name
-----------------------------------------------------------------------

Summary of changes:
 dist/constant/lib/constant.pm |   11 +++++------
 dist/constant/t/constant.t    |    8 +++++++-
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/dist/constant/lib/constant.pm b/dist/constant/lib/constant.pm
index a51ee7f..3ee1a6f 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 a42b7d2..85a9355 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 /;
+}

--
Perl5 Master Repository

Reply via email to