develooper Front page | perl.perl5.porters | Postings from September 2013

[perl #119593] Bleadperl v5.19.3-296-gffdb8b1 breaks BAREFOOT/Test-File-1.34.tar.gz

Thread Previous | Thread Next
From:
Father Chrysostomos via RT
Date:
September 7, 2013 08:20
Subject:
[perl #119593] Bleadperl v5.19.3-296-gffdb8b1 breaks BAREFOOT/Test-File-1.34.tar.gz
Message ID:
rt-3.6.HEAD-1873-1378542026-523.119593-15-0@perl.org
On Tue Sep 03 19:58:33 2013, andreas.koenig.7os6VVqR@franz.ak.mind.de wrote:
> git bisect
> ----------
> commit ffdb8b167ec4e9c0f37371dfd7b0abb01e413f90
> Author: Father Chrysostomos <sprout@cpan.org>
> Date:   Sun Sep 1 00:30:59 2013 -0700
> 
>     Fix two line numbers bugs involving quote-like ops

The Test::File failure can be reduced to:

foo(
   "@{[]}"
 . warn() # now gives line 1, not 2
 . "")

The line number returned by caller() (and used by warn) is a single
number applying to the whole statement.  A multiline statement only gets
one line number assigned to it in the op tree.

"@{[]}" used to reset the line number for the surrounding statement to
the line number of the "@{[]}" itself.  Now it has stopped doing that,
although @{[]} without quotes still does it.

The reason this happens is that PL_copline is now localised and
invalidated for the compilation of the contents of the quotes, so that
statements inside the quotes don’t pick up the line number from outside.

Test::File’s test suite is sensitive to that, as it uses
Test::Builder::Tester::line_num (which uses caller), rather than
__LINE__.  __LINE__ is not subject to the one-number-per-statement
limitation.

As long as we are limited to one line number per statement, which line
should we be aiming for?  To me, the first line makes sense, so it looks
as though I have partially fixed a bug here.

If necessary, though, I could allow changes to PL_copline inside the
quotes to leak out, but still protect code inside from the previous
PL_copline value from outside.

(For those who have no idea what I am talking about, PL_copline is set
at the beginning of certain possibly multiline constructs, and then
newSTATEOP [which creates the statement] uses that value for the line
number if it is set.  The idea is to report beginning, rather than
ending, line numbers.  Currently PL_copline is not used enough, IMO.)

> 
> diagnostics
> -----------
> Also affected: FERRENCY/Text-MicroMason-2.13.tar.gz
> 
> Sample fails not yet arrived at cpantesters. This is from
>    Text::MicroMason:
> 
>   #   Failed test 'first line of $@ describes the error location'
>   #   at t/08-errors.t line 37.
>   #                   'MicroMason compilation failed: syntax error at
>    text template (compiled at t/08-errors.t line 35) line 9, at EOF'
>   #     doesn't match '(?^:MicroMason compilation failed: syntax error
>    at text template \(compiled at t/08-errors.t line \d+\) line 8)'

So now perl reports 9 instead of 8.

>   # MicroMason compilation failed: syntax error at text template
>    (compiled at t/08-errors.t line 35) line 9, at EOF
>   #
>   #    0  # line 1 "text template (compiled at t/08-errors.t line 35)"
>   #    1  sub {
>   #    2  local $SIG{__DIE__} = sub { die "MicroMason execution
>    failed: ", @_ };
>   #    3  my @OUT; my $_out = sub {push @OUT, @_};
>   #    4  my %ARGS = @_ if ($#_ % 2);
>   #    5  push @OUT,( qq(Hello\ world\!\
>   #    6  This\ ) );
>   #    7  push @OUT,( "".do{
>   #    8   thing(
>   #    9  } );

And the syntax error is on line 9.  So that looks like a bug fix, too.

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: new
https://rt.perl.org:443/rt3/Ticket/Display.html?id=119593

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About