From: Zefram Date: Thu, 29 Apr 2010 23:02:06 +0000 (+0100) Subject: put package declaration before label in deparsing X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=98a1a1376eb18f3329f6d272d4dc3e9a7780689f;p=p5sagit%2Fp5-mst-13.2.git put package declaration before label in deparsing When deparsing a nextstate op that has both a change of package (relative to the previous nextstate) and a label, the package declaration must be emitted first, because it is syntactically impermissible for a label to prefix a package declaration. --- diff --git a/dist/B-Deparse/Deparse.pm b/dist/B-Deparse/Deparse.pm index 89bc28d..fc0125d 100644 --- a/dist/B-Deparse/Deparse.pm +++ b/dist/B-Deparse/Deparse.pm @@ -23,7 +23,7 @@ use B qw(class main_root main_start main_cv svref_2object opnumber perlstring PMf_MULTILINE PMf_SINGLELINE PMf_FOLD PMf_EXTENDED), ($] < 5.009 ? 'PMf_SKIPWHITE' : 'RXf_SKIPWHITE'), ($] < 5.011 ? 'CVf_LOCKED' : ()); -$VERSION = 0.96; +$VERSION = 0.97; use strict; use vars qw/$AUTOLOAD/; use warnings (); @@ -1380,7 +1380,6 @@ sub pp_nextstate { $self->{'curcop'} = $op; my @text; push @text, $self->cop_subs($op); - push @text, $op->label . ": " if $op->label; my $stash = $op->stashpv; if ($stash ne $self->{'curstash'}) { push @text, "package $stash;\n"; @@ -1434,6 +1433,8 @@ sub pp_nextstate { ' "' . $op->file, qq'"\n'; } + push @text, $op->label . ": " if $op->label; + return join("", @text); } diff --git a/dist/B-Deparse/t/deparse.t b/dist/B-Deparse/t/deparse.t index 331766b..e3c62ba 100644 --- a/dist/B-Deparse/t/deparse.t +++ b/dist/B-Deparse/t/deparse.t @@ -17,7 +17,7 @@ BEGIN { require feature; feature->import(':5.10'); } -use Test::More tests => 84; +use Test::More tests => 85; use Config (); use B::Deparse; @@ -628,3 +628,8 @@ my($r, $s, @a); $r = qr/foo/; @a = split(/$r/, $s, 0); (); +#### +{ + package Foo; + label: print 123; +}