From: Florian Ragwitz Date: Tue, 8 Jan 2008 19:56:47 +0000 (+0100) Subject: B::Deparse fixes for implicit smartmatching in given/when X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9210de830a7fbd3725bfbe339a3123439f97aa5d;p=p5sagit%2Fp5-mst-13.2.git B::Deparse fixes for implicit smartmatching in given/when Message-ID: <20080108185647.GD11813@perldition.org> p4raw-id: //depot/perl@32909 --- diff --git a/ext/B/B/Deparse.pm b/ext/B/B/Deparse.pm index 8230755..0472057 100644 --- a/ext/B/B/Deparse.pm +++ b/ext/B/B/Deparse.pm @@ -2115,7 +2115,7 @@ sub pp_aassign { binop(@_, "=", 7, SWAP_CHILDREN | LIST_CONTEXT) } sub pp_smartmatch { my ($self, $op, $cx) = @_; if ($op->flags & OPf_SPECIAL) { - return $self->deparse($op->first, $cx); + return $self->deparse($op->last, $cx); } else { binop(@_, "~~", 14); diff --git a/ext/B/t/deparse.t b/ext/B/t/deparse.t index a85e5ce..c2482b9 100644 --- a/ext/B/t/deparse.t +++ b/ext/B/t/deparse.t @@ -27,7 +27,7 @@ BEGIN { require feature; feature->import(':5.10'); } -use Test::More tests => 58; +use Test::More tests => 59; use B::Deparse; my $deparse = B::Deparse->new(); @@ -400,3 +400,11 @@ my $a = {}; my $b = \{}; my $c = []; my $d = \[]; +#### +# SKIP ?$] < 5.010 && "smartmatch and given/when not implemented on this Perl version" +# 51 implicit smartmatch in given/when +given ('foo') { + when ('bar') { continue; } + when ($_ ~~ 'quux') { continue; } + default { 0; } +}