diff options
author | Stephen McCamant <smcc@mit.edu> | 2004-06-28 11:26:24 -0700 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2004-07-05 16:53:54 +0000 |
commit | cf24a84005bbe3e9a7eec3a0b9eb2e5e5b89c450 (patch) | |
tree | 92776137b61e2467fcafb6e655507899175f3754 | |
parent | 6cb271b22aafa3e578dd67cc48ab658f6d61b7a2 (diff) | |
download | perl-cf24a84005bbe3e9a7eec3a0b9eb2e5e5b89c450.tar.gz |
Re: [perl #30504] B::Deparse scoping problem with for loop
Message-ID: <16608.50496.787002.560481@apocalypse.OCF.Berkeley.EDU>
p4raw-id: //depot/perl@23046
-rw-r--r-- | ext/B/B/Deparse.pm | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/ext/B/B/Deparse.pm b/ext/B/B/Deparse.pm index 73075cdf4f..adda35ffb9 100644 --- a/ext/B/B/Deparse.pm +++ b/ext/B/B/Deparse.pm @@ -1013,6 +1013,8 @@ sub maybe_local { and not $self->{'avoid_local'}{$$op}) { my $our_local = ($op->private & OPpLVAL_INTRO) ? "local" : "our"; if( $our_local eq 'our' ) { + # XXX This assertion fails code with non-ASCII identifiers, + # like ./ext/Encode/t/jperl.t die "Unexpected our($text)\n" unless $text =~ /^\W(\w+::)*\w+\z/; $text =~ s/(\w+::)+//; } @@ -2514,8 +2516,13 @@ sub loop_common { } elsif ($var->name eq "gv") { $var = "\$" . $self->deparse($var, 1); } - $head = "foreach $var ($ary) "; $body = $kid->first->first->sibling; # skip OP_AND and OP_ITER + if (!is_state $body->first and $body->first->name ne "stub") { + confess unless $var eq '$_'; + $body = $body->first; + return $self->deparse($body, 2) . " foreach ($ary)"; + } + $head = "foreach $var ($ary) "; } elsif ($kid->name eq "null") { # while/until $kid = $kid->first; my $name = {"and" => "while", "or" => "until"}->{$kid->name}; |