summaryrefslogtreecommitdiff
path: root/dist
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2010-09-20 22:05:39 -0700
committerFather Chrysostomos <sprout@cpan.org>2010-09-20 22:05:39 -0700
commita539498ab05fd838aa1eaaebbe1f3528bb97d1d3 (patch)
treec937d131edf9b5876c839b01039576545ee5b3d5 /dist
parent2474a784a94d8c70aea9c330d9f2a902b8a68b85 (diff)
downloadperl-a539498ab05fd838aa1eaaebbe1f3528bb97d1d3.tar.gz
Let B::Deparse know about the [perl #20444] fix.
With the previous commit: $ ./perl -Ilib -MO=Deparse -e'"foo" =~ (1?/foo/:/bar/)' 'foo' =~ /foo/; -e syntax OK So the Deparse output no longer matches what perl does. With this commit: $ ./perl -Ilib -MO=Deparse -e'"foo" =~ (1?/foo/:/bar/)' 'foo' =~ ($_ =~ /foo/); -e syntax OK
Diffstat (limited to 'dist')
-rw-r--r--dist/B-Deparse/Deparse.pm10
-rw-r--r--dist/B-Deparse/t/deparse.t11
2 files changed, 19 insertions, 2 deletions
diff --git a/dist/B-Deparse/Deparse.pm b/dist/B-Deparse/Deparse.pm
index f446f2ad3d..92f27476f2 100644
--- a/dist/B-Deparse/Deparse.pm
+++ b/dist/B-Deparse/Deparse.pm
@@ -4221,6 +4221,7 @@ sub matchop {
}
my $quote = 1;
my $extended = ($op->pmflags & PMf_EXTENDED);
+ my $rhs_bound_to_defsv;
if (null $kid) {
my $unbacked = re_unback($op->precomp);
if ($extended) {
@@ -4232,6 +4233,7 @@ sub matchop {
carp("found ".$kid->name." where regcomp expected");
} else {
($re, $quote) = $self->regcomp($kid, 21, $extended);
+ $rhs_bound_to_defsv = 1 if $kid->first->first->flags & OPf_SPECIAL;
}
my $flags = "";
$flags .= "c" if $op->pmflags & PMf_CONTINUE;
@@ -4250,7 +4252,13 @@ sub matchop {
}
$re = $re . $flags if $quote;
if ($binop) {
- return $self->maybe_parens("$var =~ $re", $cx, 20);
+ return
+ $self->maybe_parens(
+ $rhs_bound_to_defsv
+ ? "$var =~ (\$_ =~ $re)"
+ : "$var =~ $re",
+ $cx, 20
+ );
} else {
return $re;
}
diff --git a/dist/B-Deparse/t/deparse.t b/dist/B-Deparse/t/deparse.t
index 3a7d2aa8eb..0fc3b6c87e 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 => 89;
+use Test::More tests => 90;
use Config ();
use B::Deparse;
@@ -645,3 +645,12 @@ pop;
pop();
####
pop @_;
+####
+# 82 [perl #20444]
+"foo" =~ (1 ? /foo/ : /bar/);
+"foo" =~ (1 ? y/foo// : /bar/);
+"foo" =~ (1 ? s/foo// : /bar/);
+>>>>
+'foo' =~ ($_ =~ /foo/);
+'foo' =~ ($_ =~ tr/fo//);
+'foo' =~ ($_ =~ s/foo//);