summaryrefslogtreecommitdiff
path: root/dist
diff options
context:
space:
mode:
authorZefram <zefram@fysh.org>2010-04-30 00:02:06 +0100
committerDavid Golden <dagolden@cpan.org>2010-04-29 19:41:10 -0400
commit98a1a1376eb18f3329f6d272d4dc3e9a7780689f (patch)
treefe005b7153c0b0493705cff2633fe5347b0289c6 /dist
parenta9201296457bbaf65a658e2c85755eee4c36439a (diff)
downloadperl-98a1a1376eb18f3329f6d272d4dc3e9a7780689f.tar.gz
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.
Diffstat (limited to 'dist')
-rw-r--r--dist/B-Deparse/Deparse.pm5
-rw-r--r--dist/B-Deparse/t/deparse.t7
2 files changed, 9 insertions, 3 deletions
diff --git a/dist/B-Deparse/Deparse.pm b/dist/B-Deparse/Deparse.pm
index 89bc28dc73..fc0125d62f 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 331766bac6..e3c62baeeb 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;
+}