From d900231220b122f20e8e0a548adebb219d83cd88 Mon Sep 17 00:00:00 2001 From: Stephen McCamant Date: Sun, 29 Oct 2006 00:40:46 -0800 Subject: [PATCH] Re: Deparse bug? Message-ID: <17732.55694.646895.706177@apocalypse.OCF.Berkeley.EDU> Date: Sun, 29 Oct 2006 08:40:46 -0800 p4raw-id: //depot/perl@29133 --- ext/B/B/Deparse.pm | 15 ++++++++++----- ext/B/t/deparse.t | 7 ++++++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/ext/B/B/Deparse.pm b/ext/B/B/Deparse.pm index 3bfd0ce..b2fc7e3 100644 --- a/ext/B/B/Deparse.pm +++ b/ext/B/B/Deparse.pm @@ -1738,7 +1738,7 @@ sub pp_require { 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 padval { 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 @@ sub anon_hash_or_list { $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 & OPf_SPECIAL) { - return $self->anon_hash_or_list($op); + return $self->anon_hash_or_list($op, $cx); } warn "Unexpected op pp_" . $op->name() . " without OPf_SPECIAL"; return 'XXX'; @@ -1787,7 +1792,7 @@ sub pp_refgen { 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 " . diff --git a/ext/B/t/deparse.t b/ext/B/t/deparse.t index 02ea83c..fe601b1 100644 --- a/ext/B/t/deparse.t +++ b/ext/B/t/deparse.t @@ -24,7 +24,7 @@ use warnings; use strict; use Config; -print "1..42\n"; +print "1..43\n"; use B::Deparse; my $deparse = B::Deparse->new() or print "not "; @@ -329,3 +329,8 @@ do { () }; #### # 36 (ibid.) do { my $x = 1; $x }; +#### +# 37 <20061012113037.GJ25805@c4.convolution.nl> +my $f = sub { + +{[]}; +} ; -- 2.7.4