From: Paul Johnson Date: Sat, 19 Apr 2008 13:02:06 +0000 (+0200) Subject: Re: wrong line numbers in elsif() X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7ecdd211705c44c1696529960c8ab5c1ad8f4c65;p=p5sagit%2Fp5-mst-13.2.git Re: wrong line numbers in elsif() Message-ID: <20080419110206.GE32555@pjcj.net> p4raw-id: //depot/perl@33714 --- diff --git a/ext/B/B/Deparse.pm b/ext/B/B/Deparse.pm index 64c6dc9..c7ed82d 100644 --- a/ext/B/B/Deparse.pm +++ b/ext/B/B/Deparse.pm @@ -2589,6 +2589,12 @@ sub pp_cond_expr { my $newcond = $newop->first; my $newtrue = $newcond->sibling; $false = $newtrue->sibling; # last in chain is OP_AND => no else + if ($newcond->name eq "lineseq") + { + # lineseq to ensure correct line numbers in elsif() + # Bug #37302 fixed by change #33710. + $newcond = $newcond->first->sibling; + } $newcond = $self->deparse($newcond, 1); $newtrue = $self->deparse($newtrue, 0); push @elsifs, "elsif ($newcond) {\n\t$newtrue\n\b}"; diff --git a/ext/B/t/deparse.t b/ext/B/t/deparse.t index 5553df8..dce5034 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 => 59; +use Test::More tests => 60; use B::Deparse; my $deparse = B::Deparse->new(); @@ -409,3 +409,10 @@ given ('foo') { when ($_ ~~ 'quux') { continue; } default { 0; } } +#### +# 53 conditions in elsifs (regression in change #33710 which fixed bug #37302) +if ($a) { x(); } +elsif ($b) { x(); } +elsif ($a and $b) { x(); } +elsif ($a or $b) { x(); } +else { x(); }