Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s [foo] \n [bar] confuses line numbers #16119

Closed
p5pRT opened this issue Aug 19, 2017 · 9 comments
Closed

s [foo] \n [bar] confuses line numbers #16119

p5pRT opened this issue Aug 19, 2017 · 9 comments

Comments

@p5pRT
Copy link

p5pRT commented Aug 19, 2017

Migrated from rt.perl.org#131930 (status was 'resolved')

Searchable as RT131930$

@p5pRT
Copy link
Author

p5pRT commented Aug 19, 2017

From @Abigail

Created by @Abigail

Consider the following program​:

  #!/opt/perl/bin/perl

  use 5.010;

  say "This is line " . __LINE__;
  s [foo] [bar];

  say "This is line " . __LINE__;

  __END__

This prints, as expected​:

  This is line 5
  This is line 8

Now watch what happens if we move the replacement part of s///
to the blank line below it​:

  #!/opt/perl/bin/perl

  use 5.010;

  say "This is line " . __LINE__;
  s [foo]
  [bar];
  say "This is line " . __LINE__;

  __END__

Now it gets the second line number wrong​:

  This is line 5
  This is line 7

This also effects line numbers of errors and warnings.

Note that if the replacement part (or the pattern) contain a newline,
the line numbes are fine. It's when the pattern and replacement each
use matching braces, and there's a newline between the two sets that
we get this error.

Perl Info

Flags:
    category=core
    severity=medium

Site configuration information for perl 5.26.0:

Configured by abigail at Fri Jun  2 22:37:04 CEST 2017.

Summary of my perl5 (revision 5 version 26 subversion 0) configuration:
   
  Platform:
    osname=darwin
    osvers=10.8.0
    archname=darwin-ld-2level
    uname='darwin alexia 10.8.0 darwin kernel version 10.8.0: tue jun 7 16:33:36 pdt 2011; root:xnu-1504.15.3~1release_i386 i386 '
    config_args='-des -Dusemorebits -Uversiononly -Dperladmin=abigail@abigail.be -Dcf_email=abigail@abigail.be -Dmydomain=abigail.be -Dcc=gcc -Dprefix=/opt/perl/ -Dusedevel'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=undef
    usemultiplicity=undef
    use64bitint=define
    use64bitall=define
    uselongdouble=define
    usemymalloc=n
    default_inc_excludes_dot=define
    bincompat5005=undef
  Compiler:
    cc='gcc'
    ccflags ='-fno-common -DPERL_DARWIN -no-cpp-precomp -mmacosx-version-min=10.6 -fno-strict-aliasing -pipe -fstack-protector -I/opt/local/include -DPERL_USE_SAFE_PUTENV'
    optimize='-O3'
    cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN -no-cpp-precomp -mmacosx-version-min=10.6 -fno-strict-aliasing -pipe -fstack-protector -I/opt/local/include'
    ccversion=''
    gccversion='4.2.1 (Apple Inc. build 5666) (dot 3)'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=3
    ivtype='long'
    ivsize=8
    nvtype='long double'
    nvsize=16
    Off_t='off_t'
    lseeksize=8
    alignbytes=16
    prototype=define
  Linker and Libraries:
    ld='gcc'
    ldflags =' -mmacosx-version-min=10.6 -fstack-protector -L/opt/local/lib'
    libpth=/usr/lib /opt/local/lib
    libs=-lpthread -lgdbm -ldbm -ldl -lm -lutil -lc
    perllibs=-lpthread -ldl -lm -lutil -lc
    libc=
    so=dylib
    useshrplib=false
    libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=bundle
    d_dlsymun=undef
    ccdlflags=' '
    cccdlflags=' '
    lddlflags=' -mmacosx-version-min=10.6 -bundle -undefined dynamic_lookup -L/opt/local/lib -fstack-protector'



@INC for perl 5.26.0:
    /Users/abigail/Perl/CPAN/Regexp-Common2/lib
    /Users/abigail/Perl/CPAN/Test-Regexp/lib
    /opt/perl/lib/site_perl/5.26.0/darwin-ld-2level
    /opt/perl/lib/site_perl/5.26.0
    /opt/perl/lib/5.26.0/darwin-ld-2level
    /opt/perl/lib/5.26.0
    /opt/perl/lib/site_perl/5.24.0
    /opt/perl/lib/site_perl/5.22.0
    /opt/perl/lib/site_perl/5.20.0
    /opt/perl/lib/site_perl/5.16.3
    /opt/perl/lib/site_perl/5.16.2
    /opt/perl/lib/site_perl/5.14.4
    /opt/perl/lib/site_perl/5.14.3
    /opt/perl/lib/site_perl/5.12.5
    /opt/perl/lib/site_perl/5.10.1
    /opt/perl/lib/site_perl/5.8.9
    /opt/perl/lib/site_perl


Environment for perl 5.26.0:
    DYLD_LIBRARY_PATH (unset)
    HOME=/Users/abigail
    LANG (unset)
    LANGUAGE (unset)
    LC_CTYPE=UTF-8
    LD_LIBRARY_PATH=/Users/abigail/Lib:/usr/local/lib:/usr/lib:/lib:/usr/X11R6/lib
    LOGDIR (unset)
    PATH=/Users/abigail/Bin:/opt/perl/bin:/opt/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/games:/opt/git/bin:/Users/abigail/Perl/Photos:/Users/abigail/Perl/Bin:/opt/mysql/bin:/opt/local/bin:/Users/abigail/bin
    PERL5LIB=/Users/abigail/Perl/CPAN/Regexp-Common2/lib:/Users/abigail/Perl/CPAN/Test-Regexp/lib
    PERLDIR=/opt/perl
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Aug 20, 2017

From @cpansprout

On Sat, 19 Aug 2017 14​:40​:25 -0700, abigail@​abigail.be wrote​:

This is a bug report for perl from abigail@​abigail.be,
generated with the help of perlbug 1.40 running under perl 5.26.0.

-----------------------------------------------------------------
[Please describe your issue here]

Consider the following program​:

#!/opt/perl/bin/perl

use 5.010;

say "This is line " . __LINE__;
s [foo] [bar];

say "This is line " . __LINE__;

__END__

This prints, as expected​:

This is line 5
This is line 8

Now watch what happens if we move the replacement part of s///
to the blank line below it​:

#!/opt/perl/bin/perl

use 5.010;

say "This is line " . __LINE__;
s [foo]
[bar];
say "This is line " . __LINE__;

__END__

Now it gets the second line number wrong​:

This is line 5
This is line 7

perl5.24.2 is fine, so it was introduced some time between 5.24.0 and 5.26.0.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Aug 20, 2017

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Aug 20, 2017

From @cpansprout

On Sat, 19 Aug 2017 14​:40​:25 -0700, abigail@​abigail.be wrote​:
It's when the pattern and replacement each

use matching braces, and there's a newline between the two sets that
we get this error.

The second set does not need to use matching delimiters​:

$ perl5.27.1 -le 's<foo>' -e' /bar/;' -e' print __LINE__'
2

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Sep 11, 2017

From @iabyn

On Sat, Aug 19, 2017 at 06​:40​:24PM -0700, Father Chrysostomos via RT wrote​:

#!/opt/perl/bin/perl

use 5.010;

say "This is line " . __LINE__;
s [foo]
[bar];
say "This is line " . __LINE__;

__END__

Now it gets the second line number wrong​:

This is line 5
This is line 7

perl5.24.2 is fine, so it was introduced some time between 5.24.0 and 5.26.0.

It bisects to this. I'll have a further look sometime.

6432a58 is the first bad commit
commit 6432a58
Author​: David Mitchell <davem@​iabyn.com>
Date​: Thu Nov 10 21​:38​:30 2016 +0000

  Eliminate SVrepl_EVAL and SvEVALED()
 
  This flag is only used to indicate that the SV holding the text of the
  replacement part of a s/// has seen at least one /e.
 
  Instead, set the IVX field in the SV to a true value.
  (We already set the NVX field on that SV to indicate a multi-src-line
  substitution).
 
  This is to reduce the number of odd special cases for the SVpbm_VALID flag.

--
Justice is when you get what you deserve.
Law is when you get what you pay for.

@p5pRT
Copy link
Author

p5pRT commented Mar 7, 2018

From @iabyn

On Mon, Sep 11, 2017 at 08​:05​:59AM +0100, Dave Mitchell wrote​:

On Sat, Aug 19, 2017 at 06​:40​:24PM -0700, Father Chrysostomos via RT wrote​:

#!/opt/perl/bin/perl

use 5.010;

say "This is line " . __LINE__;
s [foo]
[bar];
say "This is line " . __LINE__;

__END__

Now it gets the second line number wrong​:

This is line 5
This is line 7

perl5.24.2 is fine, so it was introduced some time between 5.24.0 and 5.26.0.

It bisects to this. I'll have a further look sometime.

6432a58 is the first bad commit
commit 6432a58
Author​: David Mitchell <davem@​iabyn.com>
Date​: Thu Nov 10 21​:38​:30 2016 +0000

Eliminate SVrepl\_EVAL and SvEVALED\(\)

This flag is only used to indicate that the SV holding the text of the
replacement part of a s/// has seen at least one /e\.

Instead\, set the IVX field in the SV to a true value\.
\(We already set the NVX field on that SV to indicate a multi\-src\-line
substitution\)\.

Now fixed with v5.27.9-124-g823ba44

--
Red sky at night - gerroff my land!
Red sky at morning - gerroff my land!
  -- old farmers' sayings #14

@p5pRT
Copy link
Author

p5pRT commented Mar 7, 2018

@iabyn - Status changed from 'open' to 'pending release'

@p5pRT
Copy link
Author

p5pRT commented Jun 23, 2018

From @khwilliamson

Thank you for filing this report. You have helped make Perl better.

With the release yesterday of Perl 5.28.0, this and 185 other issues have been
resolved.

Perl 5.28.0 may be downloaded via​:
https://metacpan.org/release/XSAWYERX/perl-5.28.0

If you find that the problem persists, feel free to reopen this ticket.

@p5pRT
Copy link
Author

p5pRT commented Jun 23, 2018

@khwilliamson - Status changed from 'pending release' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant