This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #74740] Deparse -(f()) correctly
[perl5.git] / dist / B-Deparse / Deparse.pm
index 792cfd5..10ab498 100644 (file)
@@ -1629,7 +1629,13 @@ sub pfixop {
     my($op, $cx, $name, $prec, $flags) = (@_, 0);
     my $kid = $op->first;
     $kid = $self->deparse($kid, $prec);
-    return $self->maybe_parens(($flags & POSTFIX) ? "$kid$name" : "$name$kid",
+    return $self->maybe_parens(($flags & POSTFIX)
+                                ? "$kid$name"
+                                  # avoid confusion with filetests
+                                : $name eq '-'
+                                  && $kid =~ /^[a-zA-Z](?!\w)/
+                                       ? "$name($kid)"
+                                       : "$name$kid",
                               $cx, $prec);
 }
 
@@ -2394,7 +2400,8 @@ sub listop {
        if not $parens and not $nollafr and substr($first, 0, 1) eq "(";
     push @exprs, $first;
     $kid = $kid->sibling;
-    if (defined $proto && $proto =~ /^\*\*/ && $kid->name eq "rv2gv") {
+    if (defined $proto && $proto =~ /^\*\*/ && $kid->name eq "rv2gv"
+        && !($kid->private & OPpLVAL_INTRO)) {
        push @exprs, $self->deparse($kid->first, 6);
        $kid = $kid->sibling;
     }