diff options
author | Shlomi Fish <shlomif@shlomifish.org> | 2016-03-06 20:37:25 +0200 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2016-03-07 15:36:55 +1100 |
commit | 6ca94a7e349c01c8c0b73c24e6a957c3bd617ae6 (patch) | |
tree | 80e74ecccdeb1584b8a9ac6d734486e28301dc6f /dist/Carp | |
parent | 2dc40b2d7c20b0d31c4343ac23cda9799f234a65 (diff) | |
download | perl-6ca94a7e349c01c8c0b73c24e6a957c3bd617ae6.tar.gz |
Fix RTCPAN#107225 : longmess returns 1 on ref.
See: https://rt.cpan.org/Public/Bug/Display.html?id=107225 . Also
discovered as a bug in perl -d by me (= Shlomi Fish) and reported
after the original report. longmess() returns "1" when called in scalar
context if passed a reference.
Diffstat (limited to 'dist/Carp')
-rw-r--r-- | dist/Carp/lib/Carp.pm | 6 | ||||
-rw-r--r-- | dist/Carp/lib/Carp/Heavy.pm | 2 | ||||
-rw-r--r-- | dist/Carp/t/Carp.t | 20 |
3 files changed, 24 insertions, 4 deletions
diff --git a/dist/Carp/lib/Carp.pm b/dist/Carp/lib/Carp.pm index 9421c74211..f39302d4c0 100644 --- a/dist/Carp/lib/Carp.pm +++ b/dist/Carp/lib/Carp.pm @@ -87,7 +87,7 @@ BEGIN { } } -our $VERSION = '1.38'; +our $VERSION = '1.39'; $VERSION =~ tr/_//d; our $MaxEvalLen = 0; @@ -445,7 +445,9 @@ sub long_error_loc { } sub longmess_heavy { - return @_ if ref( $_[0] ); # don't break references as exceptions + if ( ref( $_[0] ) ) { # don't break references as exceptions + return wantarray ? @_ : $_[0]; + } my $i = long_error_loc(); return ret_backtrace( $i, @_ ); } diff --git a/dist/Carp/lib/Carp/Heavy.pm b/dist/Carp/lib/Carp/Heavy.pm index 91a42d1121..6ac932a671 100644 --- a/dist/Carp/lib/Carp/Heavy.pm +++ b/dist/Carp/lib/Carp/Heavy.pm @@ -2,7 +2,7 @@ package Carp::Heavy; use Carp (); -our $VERSION = '1.38'; +our $VERSION = '1.39'; $VERSION =~ tr/_//d; # Carp::Heavy was merged into Carp in version 1.12. Any mismatched versions diff --git a/dist/Carp/t/Carp.t b/dist/Carp/t/Carp.t index a18e3b4513..9ecdf88b60 100644 --- a/dist/Carp/t/Carp.t +++ b/dist/Carp/t/Carp.t @@ -3,7 +3,7 @@ no warnings "once"; use Config; use IPC::Open3 1.0103 qw(open3); -use Test::More tests => 65; +use Test::More tests => 66; sub runperl { my(%args) = @_; @@ -39,6 +39,24 @@ BEGIN { ); } +package MyClass; + +sub new { return bless +{ field => ['value1', 'SecondVal'] }; } + +package main; + +{ + my $err = Carp::longmess(MyClass->new); + + # See: + # https://rt.cpan.org/Public/Bug/Display.html?id=107225 + is_deeply( + $err->{field}, + ['value1', 'SecondVal',], + "longmess returns sth meaningful in scalar context when passed a ref.", + ); +} + { local $SIG{__WARN__} = sub { like $_[0], qr/ok (\d+)\n at.+\b(?i:carp\.t) line \d+\.$/, 'ok 2\n'; |