This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #31843] warnings::warn($obj,...) fails when $obj overloads ""
authorkaminsky@math.huji.ac.il <kaminsky@math.huji.ac.il>
Tue, 5 Oct 2004 09:52:07 +0000 (09:52 +0000)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Tue, 12 Oct 2004 16:07:54 +0000 (16:07 +0000)
From: kaminsky@math.huji.ac.il (via RT) <perlbug-followup@perl.org>
Message-ID: <rt-3.0.11-31843-97358.2.89612012687236@perl.org>
(with tweaks)

p4raw-id: //depot/perl@23361

lib/warnings.pm
warnings.pl

index 656b7ac..32f020e 100644 (file)
@@ -402,6 +402,8 @@ sub unimport
     ${^WARNING_BITS} = $mask ;
 }
 
+my %builtin_type; @builtin_type{qw(SCALAR ARRAY HASH CODE REF GLOB LVALUE Regexp)} = ();
+
 sub __chk
 {
     my $category ;
@@ -411,10 +413,10 @@ sub __chk
     if (@_) {
         # check the category supplied.
         $category = shift ;
-        if (ref $category) {
-            Croaker ("not an object")
-                if $category !~ /^([^=]+)=/ ;
-           $category = $;
+        if (my $type = ref $category) {
+            Croaker("not an object")
+                if exists $builtin_type{$type};
+           $category = $type;
             $isobj = 1 ;
         }
         $offset = $Offsets{$category};
index df766fe..24246f5 100644 (file)
@@ -710,6 +710,8 @@ sub unimport
     ${^WARNING_BITS} = $mask ;
 }
 
+my %builtin_type; @builtin_type{qw(SCALAR ARRAY HASH CODE REF GLOB LVALUE Regexp)} = ();
+
 sub __chk
 {
     my $category ;
@@ -719,10 +721,10 @@ sub __chk
     if (@_) {
         # check the category supplied.
         $category = shift ;
-        if (ref $category) {
-            Croaker ("not an object")
-                if $category !~ /^([^=]+)=/ ;
-           $category = $;
+        if (my $type = ref $category) {
+            Croaker("not an object")
+                if exists $builtin_type{$type};
+           $category = $type;
             $isobj = 1 ;
         }
         $offset = $Offsets{$category};