This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix context of caller call in Carp
authorGraham Knop <haarg@haarg.org>
Mon, 23 Nov 2020 22:12:49 +0000 (23:12 +0100)
committerKarl Williamson <khw@cpan.org>
Mon, 23 Nov 2020 22:26:56 +0000 (15:26 -0700)
Carp's CARP_NOT variable is meant to have package names. caller in list
context returns the calling file and line in addition to the package
name.

Enforce scalar context on the call to caller to fix this.

dist/Carp/lib/Carp.pm

index 109b7fe..46aeaa5 100644 (file)
@@ -284,7 +284,7 @@ sub shortmess {
     my $cgc = _cgc();
 
     # Icky backwards compatibility wrapper. :-(
-    local @CARP_NOT = $cgc ? $cgc->() : caller();
+    local @CARP_NOT = scalar( $cgc ? $cgc->() : caller() );
     shortmess_heavy(@_);
 }