This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix up exists etc deparsing
authorDavid Mitchell <davem@iabyn.com>
Fri, 22 Jul 2016 11:19:03 +0000 (12:19 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 3 Aug 2016 19:54:41 +0000 (20:54 +0100)
a general multideref expression like

    exists +($r//{})->{foo}

was being deparsed without the '+', meaning it was being interpreted
as

    (exists ($r//{}))->{foo}

lib/B/Deparse.pm

index 16b813a..c5b7415 100644 (file)
@@ -4030,7 +4030,11 @@ sub pp_multideref {
 
     if ($op->first && ($op->first->flags & OPf_KIDS)) {
         # arbitrary initial expression, e.g. f(1,2,3)->[...]
-        $text .=  $self->deparse($op->first, 24);
+        my $expr = $self->deparse($op->first, 24);
+        # stop "exists (expr)->{...}" being interpreted as
+        #"(exists (expr))->{...}"
+        $expr = "+$expr" if $expr =~ /^\(/;
+        $text .=  $expr;
     }
 
     my @items = $op->aux_list($self->{curcv});