From: Rick Delaney Date: Sat, 2 Oct 2004 01:04:49 +0000 (-0400) Subject: Re: [perl #31793] Data::Dumper: Useqq interacts badly with overloading X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d411a6a9eb5df09116806ed1c441d30d37e8d5e8;p=p5sagit%2Fp5-mst-13.2.git Re: [perl #31793] Data::Dumper: Useqq interacts badly with overloading Message-ID: <20041002050448.GB5059@biff.bort.ca> p4raw-id: //depot/perl@23347 --- diff --git a/lib/overload.pm b/lib/overload.pm index a75c817..1853499 100644 --- a/lib/overload.pm +++ b/lib/overload.pm @@ -94,7 +94,7 @@ sub AddrRef { } sub StrVal { - (ref $_[0] && OverloadedStringify($_[0]) or ref($_[0]) eq 'Regexp') ? + (ref $_[0] && Overloaded($_[0]) or ref($_[0]) eq 'Regexp') ? (AddrRef(shift)) : "$_[0]"; } diff --git a/lib/overload.t b/lib/overload.t index 519c6d8..c1b92c5 100644 --- a/lib/overload.t +++ b/lib/overload.t @@ -1097,8 +1097,6 @@ test ($a->xet('b'), 42); test (!defined eval { $a->{b} }); test ($@ =~ /zap/); -test (overload::StrVal(qr/a/) =~ /^Regexp=SCALAR\(0x[0-9a-f]+\)$/); - { package t229; use overload '=' => sub { 42 }, @@ -1139,6 +1137,23 @@ test (overload::StrVal(qr/a/) =~ /^Regexp=SCALAR\(0x[0-9a-f]+\)$/); sub numify { ${$_[0]} } } +{ + package perl31793; + use overload cmp => sub { 0 }; + package main; + my $o = bless [], 'perl31793'; + my $no = bless [], 'no_overload'; + test (overload::StrVal(\"scalar") =~ /^SCALAR\(0x[0-9a-f]+\)$/); + test (overload::StrVal([]) =~ /^ARRAY\(0x[0-9a-f]+\)$/); + test (overload::StrVal({}) =~ /^HASH\(0x[0-9a-f]+\)$/); + test (overload::StrVal(sub{1}) =~ /^CODE\(0x[0-9a-f]+\)$/); + test (overload::StrVal(\*GLOB) =~ /^GLOB\(0x[0-9a-f]+\)$/); + test (overload::StrVal(\$o) =~ /^REF\(0x[0-9a-f]+\)$/); + test (overload::StrVal(qr/a/) =~ /^Regexp=SCALAR\(0x[0-9a-f]+\)$/); + test (overload::StrVal($o) =~ /^perl31793=ARRAY\(0x[0-9a-f]+\)$/); + test (overload::StrVal($no) =~ /^no_overload=ARRAY\(0x[0-9a-f]+\)$/); +} + # These are all check that overloaded values rather than reference addressess # are what is getting tested. my ($two, $one, $un, $deux) = map {new Numify $_} 2, 1, 1, 2; @@ -1160,4 +1175,4 @@ foreach my $op (qw(<=> == != < <= > >=)) { } } # Last test is: -sub last {484} +sub last {492}