Change 29133 by nicholas@ballet-shoe on 2006/10/29 19:27:45
Subject: [PATCH] Re: Deparse bug?
From: Stephen McCamant <smcc (AT) mit (DOT) edu>
Message-ID: <17732.55694.646895.706177 (AT) CF (DOT) Berkeley.EDU>
Date: Sun, 29 2006 08:40:46 -0800
Affected files
//depot/perl/ext/B/B/Deparse.pm#171 edit
//depot/perl/ext/B/t/deparse.t#24 edit
Differences
//depot/perl/ext/B/B/Deparse.pm#171 (text)
Index: perl/ext/B/B/Deparse.pm
perl/ext/B/B/Deparse.pm#170~29062~2006-10-20 04:51:57.000000000 -0700
perl/ext/B/B/Deparse.pm2006-10-29 11:27:45.000000000 -0800
@@ -1738,7 +1738,7 @@
sub pp_scalar {
my $self = shift;
- my($op, $cv) = @_;
+ my($op, $cx) = @_;
my $kid = $op->first;
if (not null $kid->sibling) {
# XXX Was a here-doc
@@ -1756,7 +1756,7 @@
sub anon_hash_or_list {
my $self = shift;
- my $op = shift;
+ my($op, $cx) = @_;
my($pre, $post) = @{{"anonlist" =["[","]"],
"anonhash" =["{","}"]}->{$op->name}};
@@ -1766,13 +1766,18 @@
$expr = $self->deparse($op, 6);
push @exprs, $expr;
}
+ if ($pre eq "{" and $cx < 1) {
+# Disambiguate that it's not a block
+$pre = "+{";
+ }
return $pre . join(", ", @exprs) . $post;
}
sub pp_anonlist {
- my ($self, $op) = @_;
+ my $self = shift;
+ my ($op, $cx) = @_;
if ($op->flags & Pf_SPECIAL) {
-return $self->anon_hash_or_list($op);
+return $self->anon_hash_or_list($op, $cx);
}
warn "Unexpected op pp_" . $op->name() . " without Pf_SPECIAL";
return 'XXX';
@@ -1787,7 +1792,7 @@
if ($kid->name eq "null") {
$kid = $kid->first;
if ($kid->name eq "anonlist" || $kid->name eq "anonhash") {
- return $self->anon_hash_or_list($op);
+ return $self->anon_hash_or_list($op, $cx);
} elsif (!null($kid->sibling) and
$kid->sibling->name eq "anoncode") {
return "sub " .
//depot/perl/ext/B/t/deparse.t#24 (text)
Index: perl/ext/B/t/deparse.t
perl/ext/B/t/deparse.t#23~28656~2006-08-04 02:20:31.000000000 -0700
perl/ext/B/t/deparse.t2006-10-29 11:27:45.000000000 -0800
@@ -24,7 +24,7 @@
use strict;
use Config;
-print "142\n";
+print "143\n";
use B::Deparse;
my $deparse = B::Deparse->new() or print "not ";
@@ -329,3 +329,8 @@
# 36 (ibid.)
do { my $x = 1; $x };
+# 37 <20061012113037.GJ25805 (AT) c4 (DOT) convolution.nl>
+my $f = sub {
+ +{[]};
+} ;
End of Patch.