[perl #97476] Deparse not() following the llafr
authorFather Chrysostomos <sprout@cpan.org>
Thu, 8 Dec 2011 22:53:50 +0000 (14:53 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Thu, 8 Dec 2011 22:55:00 +0000 (14:55 -0800)
not() follows the looks-like-a-function rule, unlike its high-prece-
dence counterpart.  So deparsing

    not +($foo || die) && $baz

as

    not ($foo || die) && $baz

is incorrect, as the && $baz part is no longer part of the argu-
ment to not().

dist/B-Deparse/Deparse.pm
dist/B-Deparse/t/deparse.t

index b751dc5..977ce4d 100644 (file)
@@ -1666,7 +1666,7 @@ sub pp_not {
     my $self = shift;
     my($op, $cx) = @_;
     if ($cx <= 4) {
-       $self->pfixop($op, $cx, $self->keyword("not")." ", 4);
+       $self->listop($op, $cx, "not", $op->first);
     } else {
        $self->pfixop($op, $cx, "!", 21);       
     }
index b852a0c..2c3efd5 100644 (file)
@@ -876,6 +876,9 @@ CORE::do({});
 () = (-w $_) + 3;
 () = (-x $_) + 3;
 ####
+# [perl #97476] not() *does* follow the llafr
+$_ = ($a xor not +($1 || 2) ** 2);
+####
 # Precedence conundrums with argument-less function calls
 () = (eof) + 1;
 () = (return) + 1;