From: Simon Cozens <simon@netthink.co.uk>
Date: Sun, 10 Dec 2000 19:06:19 +0000 (+0000)
Subject: Re: [ID 20001204.007] -MO=Deparse -we '{234;}' failing
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1e1dbab6eed49955498a66ce3beedbd7ea33dc21;p=p5sagit%2Fp5-mst-13.2.git

Re: [ID 20001204.007] -MO=Deparse -we '{234;}' failing
Message-ID: <20001210190619.B21402@deep-dark-truthful-mirror.perlhacker.org>

p4raw-id: //depot/perl@8079
---

diff --git a/ext/B/B/Deparse.pm b/ext/B/B/Deparse.pm
index 7d16752..37c0855 100644
--- a/ext/B/B/Deparse.pm
+++ b/ext/B/B/Deparse.pm
@@ -1792,7 +1792,7 @@ sub pp_leaveloop {
        my $state = $kid->first;
        my $cuddle = $self->{'cuddle'};
        my($expr, @exprs);
-       for (; $$state != $$cont; $state = $state->sibling) {
+       for (; $$state != $$cont and can $state "sibling"; $state = $state->sibling) {
 	   $expr = "";
 	   if (is_state $state) {
 	       $expr = $self->deparse($state, 0);
@@ -1803,8 +1803,12 @@ sub pp_leaveloop {
 	   push @exprs, $expr if $expr;
        }
        $kid = join(";\n", @exprs);
+       if (class($cont) eq "LISTOP") {
        $cont = $cuddle . "continue {\n\t" .
 	 $self->deparse($cont, 0) . "\n\b}\cK";
+       } else {
+	   $cont = "\cK";
+       }
     } else {
 	$cont = "\cK";
 	$kid = $self->deparse($kid, 0);
diff --git a/t/lib/b.t b/t/lib/b.t
index ee49213..cd5d61a 100755
--- a/t/lib/b.t
+++ b/t/lib/b.t
@@ -10,7 +10,7 @@ use warnings;
 use strict;
 use Config;
 
-print "1..15\n";
+print "1..17\n";
 
 my $test = 1;
 
@@ -78,9 +78,6 @@ LINE: while (defined($_ = <ARGV>)) {
     @F = split(/\s+/, $_, 0);
     '???'
 }
-continue {
-    '???'
-}
 
 EOF
 print "# [$a]\n\# vs\n# [$b]\nnot " if $a ne $b;
@@ -146,3 +143,14 @@ if ($is_thread) {
     print "# [$a]\nnot " unless $a =~ /sv_undef.*PVNV.*%one.*sv_undef.*HV/s;
 }
 ok;
+
+# Bug 20001204.07
+{
+my $foo = $deparse->coderef2text(sub { { 234; }});
+# Constants don't get optimised here.
+print "not " unless $foo =~ /{.*{.*234;.*}.*}/sm;
+ok;
+$foo = $deparse->coderef2text(sub { { 234; } continue { 123; } });
+print "not " unless $foo =~ /{.*{.*234;.*}.*continue.*{.*123.*}/sm; 
+ok;
+}