In perl.git, the branch sprout/carp-strval has been updated

<https://perl5.git.perl.org/perl.git/commitdiff/4dd27c818de7e7816be57b28d52738bc661a504c?hp=c6edd2e99cc4d0329c61165ff9fa4b453622d6b4>

  discards  c6edd2e99cc4d0329c61165ff9fa4b453622d6b4 (commit)
- Log -----------------------------------------------------------------
commit 4dd27c818de7e7816be57b28d52738bc661a504c
Author: Father Chrysostomos <spr...@cpan.org>
Date:   Mon Feb 26 01:23:53 2018 -0800

    Carp: Avoid run-time mods; StrVal workarounds
    
    Carp needs to avoid loading modules while reporting errors, because
    it may be invoked via $SIG{__DIE__} after a syntax error, when BEGIN
    blocks are forbidden.
    
    Before this commit (as of v5.27.8-360-gc99363a) it was doing just that
    for reference arguments within stack traces.
    
    That means we either need to load overload.pm at start-up so that
    overload::StrVal is already available, or avoid overload::StrVal
    altogether.
    
    It turns out that various versions of overload::StrVal have
    their own problems that prevent Carp from using them (out-
    lined in the comments added to Carp.pm and also described at
    <https://rt.perl.org/Ticket/Display.html?id=132902#txn-1535564>).
    
    So we now follow two approaches:  If overloading.pm is available, use
    that; otherwise, use a hideous workaround inspired by ancient imple-
    entations of overload::StrVal and Scalar::Util::blessed, while avoid-
    ing the bugs in those old versions.

-----------------------------------------------------------------------

Summary of changes:
 dist/Carp/lib/Carp.pm         | 4 ++--
 dist/Carp/t/stack_after_err.t | 8 ++++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/dist/Carp/lib/Carp.pm b/dist/Carp/lib/Carp.pm
index 632fd6abae..d403021fc2 100644
--- a/dist/Carp/lib/Carp.pm
+++ b/dist/Carp/lib/Carp.pm
@@ -172,7 +172,7 @@ BEGIN {
                 local *$probe = sub { "unlikely string" };
                 local $@;
                 local $SIG{__DIE__} = sub{};
-                eval { $_[0]->$probe } eq 'unilkely string'
+                eval { $_[0]->$probe } eq 'unlikely string'
               }
             : do {
                 my $isa = _fetch_sub(qw 'UNIVERSAL isa');
@@ -182,7 +182,7 @@ BEGIN {
         *_StrVal = sub {
             my $pack = ref $_[0];
             # Perl's overload mechanism uses the presence of a special
-            # "method" named "((" or "()" to signal it it is effect.
+            # "method" named "((" or "()" to signal it is in effect.
             # This test seeks to see if it has been set up.  "((" post-
             # dates overloading.pm, so we can skip it.
             return "$_[0]" unless _mycan($pack, "()");
diff --git a/dist/Carp/t/stack_after_err.t b/dist/Carp/t/stack_after_err.t
index 8f4e539b3c..8bf5be965a 100644
--- a/dist/Carp/t/stack_after_err.t
+++ b/dist/Carp/t/stack_after_err.t
@@ -28,13 +28,15 @@ like(
           }
           BEGIN {
               *{"o::()"} = sub {};
+              *{'o::(""'} = sub {"hay"};
+              $o::OVERLOAD{dummy}++; # perls before 5.18 need this
               *{"CODE::()"} = sub {};
               $SIG{__DIE__} = sub { foom (@_, bless([], o), sub {}) }
           }
         $a +
         >,
     ),
-    qr 'Looks lark.*o=ARRAY's,
+    qr 'Looks lark.*o=ARRAY.* CODE's,
    'Carp does not try to load modules on demand for overloaded args',
 );
 
@@ -50,6 +52,8 @@ my $prog = q<
           }
           BEGIN {
               *{"o::()"} = sub {};
+              *{'o::(""'} = sub {"hay"};
+              $o::OVERLOAD{dummy}++; # perls before 5.18 need this
               *{"CODE::()"} = sub {};
               $SIG{__DIE__} = sub { foom (@_, bless([], o), sub{}) }
           }
@@ -63,7 +67,7 @@ for (
 ) {
     my ($tn, $preamble) = @$_;
     like(runperl( prog => "$preamble$prog" ),
-         qr 'Looks lark.*o=ARRAY's,
+         qr 'Looks lark.*o=ARRAY.* CODE's,
         "StrVal fallback in the presence of $tn",
     )
 }

-- 
Perl5 Master Repository

Reply via email to