Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.97k stars 560 forks source link

Strange regex failure? #7917

Closed p5pRT closed 16 years ago

p5pRT commented 19 years ago

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

Searchable as RT35877$

p5pRT commented 19 years ago

From @steve-m-hay

This is a bug report for perl from steve.hay@​uk.radan.com\, generated with the help of perlbug 1.35 running under perl v5.8.6.

I believe that the following program should print "OK" 5 times over\, but it prints "NOT OK" from the first line.

print qq[>10\n] =~ />\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>1\n] =~ />\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ /\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ />\d\d$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ />\d+$ \n/x ? "OK\n" : "NOT OK\n";

I get the same behaviour with 5.6.0 through to 5.8.6 and bleadperl\, all on Windows XP.


Flags​:   category=core   severity=medium


Site configuration information for perl v5.8.6​:

Configured by steveh at Tue Dec 7 11​:33​:40 2004.

Summary of my perl5 (revision 5 version 8 subversion 6) configuration​:   Platform​:   osname=MSWin32\, osvers=4.0\, archname=MSWin32-x86-perlio   uname=''   config_args='undef'   hint=recommended\, useposix=true\, d_sigaction=undef   usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef   useperlio=define d_sfio=undef uselargefiles=undef usesocks=undef   use64bitint=undef use64bitall=undef uselongdouble=undef   usemymalloc=y\, bincompat5005=undef   Compiler​:   cc='cl'\, ccflags ='-nologo -Gf -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DPERL_DEBUGGING_MSTATS -DUSE_PERLIO -DPERL_MSVCRT_READFIX'\,   optimize='-MD -Zi -DNDEBUG -O1'\,   cppflags='-DWIN32'   ccversion=''\, gccversion=''\, gccosandvers=''   intsize=4\, longsize=4\, ptrsize=4\, doublesize=8\, byteorder=1234   d_longlong=undef\, longlongsize=8\, d_longdbl=define\, longdblsize=10   ivtype='long'\, ivsize=4\, nvtype='double'\, nvsize=8\, Off_t='off_t'\, lseeksize=4   alignbytes=8\, prototype=define   Linker and Libraries​:   ld='link'\, ldflags ='-nologo -nodefaultlib -debug -opt​:ref\,icf
-libpath​:"C​:\perl5\lib\CORE" -machine​:x86'   libpth=C​:\PROGRA~1\MICROS~2\VC98\lib   libs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib
netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib msvcrt.lib   perllibs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib
version.lib odbc32.lib odbccp32.lib msvcrt.lib   libc=msvcrt.lib\, so=dll\, useshrplib=yes\, libperl=perl58.lib   gnulibc_version='undef'   Dynamic Linking​:   dlsrc=dl_win32.xs\, dlext=dll\, d_dlsymun=undef\, ccdlflags=' '   cccdlflags=' '\, lddlflags='-dll -nologo -nodefaultlib -debug -opt​:ref\,icf -libpath​:"C​:\perl5\lib\CORE" -machine​:x86'

Locally applied patches​:  


@​INC for perl v5.8.6​:   C​:/perl5/lib   C​:/perl5/site/lib   .


Environment for perl v5.8.6​:   HOME (unset)   LANG (unset)   LANGUAGE (unset)   LD_LIBRARY_PATH (unset)   LOGDIR (unset)  
PATH=C​:\WINDOWS\system32;C​:\WINDOWS;C​:\WINDOWS\System32\Wbem;C​:\perl5\bin;C​:\Program Files\Perforce   PERL_BADLANG (unset)   SHELL (unset)


Radan Computational Ltd.

The information contained in this message and any files transmitted with it are confidential and intended for the addressee(s) only. If you have received this message in error or there are any problems\, please notify the sender immediately. The unauthorized use\, disclosure\, copying or alteration of this message is strictly forbidden. Note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of Radan Computational Ltd. The recipient(s) of this message should check it and any attached files for viruses​: Radan Computational will accept no liability for any damage caused by any virus transmitted by this email.

p5pRT commented 19 years ago

From @rgs

Steve Hay (via RT) wrote​:

I believe that the following program should print "OK" 5 times over\, but it prints "NOT OK" from the first line.

print qq[>10\n] =~ />\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>1\n] =~ />\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ /\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ />\d\d$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ />\d+$ \n/x ? "OK\n" : "NOT OK\n";

It appears that you must put the \n before the $ (which makes kind of sense\, \n being part of the line it ends) :

$ perl -le 'print qq[>10\n] =~ / > \d + \n $ /ix ? "OK" : "NOT OK";' OK

p5pRT commented 19 years ago

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

p5pRT commented 19 years ago

From @demerphq

I believe that the following program should print "OK" 5 times over\, but it prints "NOT OK" from the first line.

Do you mean the first test fails only (which is what I see) or that all of them fail?

print qq[>10\n] =~ />\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>1\n] =~ />\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ /\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ />\d\d$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ />\d+$ \n/x ? "OK\n" : "NOT OK\n";

I get the same behaviour with 5.6.0 through to 5.8.6 and bleadperl\, all on Windows XP.

Heres the output from the first two in the list\, it looks like a problem with STCLASS optimization.

NOT OK Compiling REx `>\d+$ \n' size 8 first at 1   1​: EXACTF \<>>(3)   3​: PLUS(5)   4​: DIGIT(0)   5​: EOL(6)   6​: EXACTF \<

(8)   8​: END(0) floating `'$ at 2..2 (checking floating) stclass `EXACTF \<>>' minlen 3 Guessing start of match\, REx `>\d+$ \n' against `>10 '... Found floating substr `'$ at offset 3... Starting position does not contradict /^/m... This position contradicts STCLASS... Could not match STCLASS... Match rejected by optimizer Freeing REx​: `>\d+$ \n'

OK Compiling REx `>\d+$ \n' size 8 first at 1   1​: EXACTF \<>>(3)   3​: PLUS(5)   4​: DIGIT(0)   5​: EOL(6)   6​: EXACTF \<

(8)   8​: END(0) floating `'$ at 2..2 (checking floating) stclass `EXACTF \<>>' minlen 3 Guessing start of match\, REx `>\d+$ \n' against `>1 '... Found floating substr `'$ at offset 2... Does not contradict STCLASS... Guessed​: match at offset 0 Matching REx `>\d+$ \n' against `>1 '   Setting an EVAL scope\, savestack=3   0 \<> \<>1 | 1​: EXACTF \<>>   1 \<>> \<1 | 3​: PLUS   DIGIT can match 1 times out of 32767...   Setting an EVAL scope\, savestack=3   2 \<>1> \< | 5​: EOL   2 \<>1> \< | 6​: EXACTF \<

  3 \<>1 \<> | 8​: END Match successful! Freeing REx​: `>\d+$ \n'

p5pRT commented 19 years ago

From @steve-m-hay

Rafael Garcia-Suarez wrote​:

Steve Hay (via RT) wrote​:

I believe that the following program should print "OK" 5 times over\, but it prints "NOT OK" from the first line.

print qq[>10\n] =~ />\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>1\n] =~ />\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ /\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ />\d\d$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ />\d+$ \n/x ? "OK\n" : "NOT OK\n";

It appears that you must put the \n before the $ (which makes kind of sense\, \n being part of the line it ends) :

$ perl -le 'print qq[>10\n] =~ / > \d + \n $ /ix ? "OK" : "NOT OK";' OK

But according to

http​://search.cpan.org/~nwclark/perl-5.8.6/pod/perlre.pod#Regular_Expressions

the /m modifier should make $ match *before* any newline. (And normally\, without the /m modifier\, it matches *before* the newline at the end of the string.)

So is it a case of the docs being wrong?


Radan Computational Ltd.

The information contained in this message and any files transmitted with it are confidential and intended for the addressee(s) only. If you have received this message in error or there are any problems\, please notify the sender immediately. The unauthorized use\, disclosure\, copying or alteration of this message is strictly forbidden. Note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of Radan Computational Ltd. The recipient(s) of this message should check it and any attached files for viruses​: Radan Computational will accept no liability for any damage caused by any virus transmitted by this email.

p5pRT commented 19 years ago

From @hvds

"Orton\, Yves" \yves\.orton@&#8203;de\.mci\.com wrote​: [Steve Hay wrote​:] :> I believe that the following program should print "OK" 5 :> times over\, but it prints "NOT OK" from the first line. : :Do you mean the first test fails only (which is what I see) or that all of :them fail?

I also see just the first fail - I think Steve typo'd 'from' for 'for'.

:> print qq[>10\n] =~ />\d+$ \n/ix ? "OK\n" : "NOT OK\n"; :> print qq[>1\n] =~ />\d+$ \n/ix ? "OK\n" : "NOT OK\n"; :> print qq[>10\n] =~ /\d+$ \n/ix ? "OK\n" : "NOT OK\n"; :> print qq[>10\n] =~ />\d\d$ \n/ix ? "OK\n" : "NOT OK\n"; :> print qq[>10\n] =~ />\d+$ \n/x ? "OK\n" : "NOT OK\n";

:Heres the output from the first two in the list\, it looks like a problem :with STCLASS optimization.

I think rather it is a problem with the floating substr check; we see​:

:floating `'$ at 2..2 (checking floating) stclass `EXACTF \<>>' minlen 3

.. all of which are correct except that the /$/ can appear anywhere in (2..inf)\, due to the preceding /\d+/ - "2..2" would be correct only if the /$/ was required to match at a point exactly 2 characters after any start-of-match.

Because of the 2..2\, when it then "Found floating substr `'$ at offset 3"\, it knew that the actual match must start at offset (3-2 == 1)\, so it looked for the stclass />/i at offset 1\, failed to find it\, and so aborted.

I notice that when the /\n/ is omitted​:

floating `'$ at 2..2147483647 (checking floating) stclass `EXACTF \<>>' minlen 2

or when the useless //i flag is removed​:

anchored `>' at 0 floating ` ' at 2..2147483647 (checking floating) minlen 3

the answers are correct\, so somehow the combination is messing up the analyser\, probably somewhere in the morass of study_chunk().

(It isn't the //x flag\, as output for m'>\d+$\n'i shows the same problem.)

Hugo

p5pRT commented 19 years ago

From @ysth

On Thu\, May 19\, 2005 at 02​:03​:45PM +0100\, Steve Hay wrote​:

Rafael Garcia-Suarez wrote​:

Steve Hay (via RT) wrote​:

I believe that the following program should print "OK" 5 times over\, but it prints "NOT OK" from the first line.

print qq[>10\n] =~ />\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>1\n] =~ />\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ /\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ />\d\d$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ />\d+$ \n/x ? "OK\n" : "NOT OK\n";

It appears that you must put the \n before the $ (which makes kind of sense\, \n being part of the line it ends) :

$ perl -le 'print qq[>10\n] =~ / > \d + \n $ /ix ? "OK" : "NOT OK";' OK

You shouldn't have to.

But according to

http​://search.cpan.org/~nwclark/perl-5.8.6/pod/perlre.pod#Regular_Expressions

the /m modifier should make $ match *before* any newline. (And normally\, without the /m modifier\, it matches *before* the newline at the end of the string.)

So is it a case of the docs being wrong?

$ can match 0-width before a newline or it can match the newline itself. Either with or without /m (which just controls whether the newline needs to be at the end of the string).

Last I checked\, that's what the docs say; do they not somewhere?

p5pRT commented 17 years ago

From @smpeters

On Thu May 19 03​:49​:55 2005\, shay wrote​:

This is a bug report for perl from steve.hay@​uk.radan.com\, generated with the help of perlbug 1.35 running under perl v5.8.6.

I believe that the following program should print "OK" 5 times over\, but it prints "NOT OK" from the first line.

print qq[>10\n] =~ />\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>1\n] =~ />\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ /\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ />\d\d$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ />\d+$ \n/x ? "OK\n" : "NOT OK\n";

I get the same behaviour with 5.6.0 through to 5.8.6 and bleadperl\, all on Windows XP.

I just ran this with a recent blead and got...

[steve@​sulu ~]$ /tmp/bleadperl/bin/perl5.10.0 rt_35877.t OK OK OK OK OK

Can you a few other people double check just to make sure this isn't a heisenbug?

Thanks\,

Steve Peters

p5pRT commented 17 years ago

From @steve-m-hay

Steve Peters via RT wrote​:

On Thu May 19 03​:49​:55 2005\, shay wrote​:

This is a bug report for perl from steve.hay@​uk.radan.com\, generated with the help of perlbug 1.35 running under perl v5.8.6.

I believe that the following program should print "OK" 5 times over\, but it prints "NOT OK" from the first line.

print qq[>10\n] =~ />\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>1\n] =~ />\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ /\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ />\d\d$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ />\d+$ \n/x ? "OK\n" : "NOT OK\n";

I get the same behaviour with 5.6.0 through to 5.8.6 and bleadperl\, all on Windows XP.

I just ran this with a recent blead and got...

[steve@​sulu ~]$ /tmp/bleadperl/bin/perl5.10.0 rt_35877.t OK OK OK OK OK

Can you a few other people double check just to make sure this isn't a heisenbug?

Thanks\,

Steve Peters

You're right--it seems to be fixed in current bleadperl (32330). It's still broken in maintperl at the moment\, though (328).

p5pRT commented 16 years ago

p5p@spam.wizbit.be - Status changed from 'open' to 'resolved'

p5pRT commented 16 years ago

p5p@spam.wizbit.be - Status changed from 'resolved' to 'open'

p5pRT commented 16 years ago

From p5p@spam.wizbit.be

On Thu May 19 03​:49​:55 2005\, shay wrote​:

I believe that the following program should print "OK" 5 times over\, but it prints "NOT OK" for the first line.

#!/usr/bin/perl

print qq[>10\n] =~ />\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>1\n] =~ />\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ /\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ />\d\d$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ />\d+$ \n/x ? "OK\n" : "NOT OK\n";

__END__

5.8.8​:

NOT OK OK OK OK OK

5.10/blead​: OK OK OK OK OK

While checking if a test for it exists/while writing one I decied to check if the /x was needed​:

#!/usr/bin/perl

print qq[>10\n] =~ />\d+$\n/i ? "OK\n" : "NOT OK\n"; print qq[>1\n] =~ />\d+$\n/i ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ /\d+$\n/i ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ />\d\d$\n/i ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ />\d+$\n/ ? "OK\n" : "NOT OK\n";

__END__ Output​:

NOT OK NOT OK NOT OK NOT OK NOT OK

Is this intended/expected behaviour?

"a\n" =~ m/a$ \n/x; # true "a\n" =~ m/a$\n/x; # false "a\n" =~ m/a$\n/; # false

Kind regards\,

Bram

p5pRT commented 16 years ago

From zefram@fysh.org

Bram via RT wrote​:

Is this intended/expected behaviour?

"a\n" =~ m/a$ \n/x; # true "a\n" =~ m/a$\n/x; # false

The latter is expected​: $\ gets interpolated.

$ perl -lwe 'print qr/a$\n/' (?-xism​:a n) $

-zefram

p5pRT commented 16 years ago

From @davidnicol

On Sun\, May 25\, 2008 at 8​:24 AM\, Zefram \zefram@&#8203;fysh\.org wrote​:

The latter is expected​: $\ gets interpolated.

Warn that non-final $ will interpolate in documentation and suggest \Z instead?

p5pRT commented 16 years ago

From david@landgren.net

David Nicol wrote\, some time around 27/05/2008 18​:25​:

On Sun\, May 25\, 2008 at 8​:24 AM\, Zefram \zefram@&#8203;fysh\.org wrote​:

The latter is expected​: $\ gets interpolated.

Warn that non-final $ will interpolate in documentation and suggest \Z instead?

Patch welcome. Your mission\, should you choose to accept it\, is to remove an equivalent budget of words (plus one) elsewhere from the documentation that it takes you to explain this aspect.

David

-- stubborn tiny lights vs. clustering darkness forever ok?

p5pRT commented 16 years ago

From p5p@perl.wizbit.be

Quoting David Nicol \davidnicol@&#8203;gmail\.com​:

On Sun\, May 25\, 2008 at 8​:24 AM\, Zefram \zefram@&#8203;fysh\.org wrote​:

The latter is expected​: $\ gets interpolated.

Warn that non-final $ will interpolate in documentation and suggest
\Z instead?

Given how easy it is to miss it I feel more for a 'Possible unintended interpolation of $\ in regex' warning. (if that
is even possible of course)

It will\, obviously\, result in false posistives in some regexes...
(although I can't remember ever using $\ in a re)

Doing a grep on perl-current seems to get only this as relevant lines​:
(assuming I didn't remove too much\, started with​: grep -r '[^\\]\$\\'
* and then removing irrelevant lines)

ext/Compress/Raw/Zlib/private/MakeUtil.pm​: exit 1 if
/^\s*local\s*\(\s*\$$\^W\s*\)/; \ ext/Compress/Zlib/private/MakeUtil.pm​: exit 1 if
/^\s*local\s*\(\s*\$$\^W\s*\)/; \ ext/IO_Compress_Base/private/MakeUtil.pm​: exit 1 if
/^\s*local\s*\(\s*\$$\^W\s*\)/; \ ext/IO_Compress_Zlib/private/MakeUtil.pm​: exit 1 if
/^\s*local\s*\(\s*\$$\^W\s*\)/; \

Looking at the one in Compress​::Zlib​::private​::MakeUtil​:

  my $postamble = '

MyTrebleCheck​:   @​echo Checking for $$^W in files​: '. "@​files" . '   @​perl -ne \' \   exit 1 if /^\s*local\s*\(\s*\$$\^W\s*\)/; \   \' ' . " @​files || " . ' \   (echo found unexpected $$^W ; exit 1)   @​echo All is ok.

';

(Which leaves me wondering if it is intended or not)

Any comments on the warning?

Kind regards\,

Bram

p5pRT commented 16 years ago

From @ysth

On Mon\, June 2\, 2008 1​:52 pm\, Bram wrote​:

Quoting David Nicol \davidnicol@&#8203;gmail\.com​:

Warn that non-final $ will interpolate in documentation and suggest \Z instead?

Given how easy it is to miss it I feel more for a 'Possible unintended interpolation of $\ in regex' warning. (if that is even possible of course)

Any comments on the warning?

Sounds great\, if you can make it suppressable with ${\}.

p5pRT commented 16 years ago

From p5p@spam.wizbit.be

On Fri Nov 16 06​:46​:06 2007\, stmpeters wrote​:

On Thu May 19 03​:49​:55 2005\, shay wrote​:

This is a bug report for perl from steve.hay@​uk.radan.com\, generated with the help of perlbug 1.35 running under perl v5.8.6.

I believe that the following program should print "OK" 5 times over\, but it prints "NOT OK" from the first line.

print qq[>10\n] =~ />\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>1\n] =~ />\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ /\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ />\d\d$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ />\d+$ \n/x ? "OK\n" : "NOT OK\n";

I get the same behaviour with 5.6.0 through to 5.8.6 and bleadperl\, all on Windows XP.

I just ran this with a recent blead and got...

[steve@​sulu ~]$ /tmp/bleadperl/bin/perl5.10.0 rt_35877.t OK OK OK OK OK

Can you a few other people double check just to make sure this isn't a heisenbug?

Thanks\,

Steve Peters

I'm not sure if tests for this were added so a patch with the tests of the report is attached.

Kind regards\,

Bram

p5pRT commented 16 years ago

From p5p@spam.wizbit.be

re_35877

p5pRT commented 16 years ago

From @steve-m-hay

Bram via RT wrote​:

On Fri Nov 16 06​:46​:06 2007\, stmpeters wrote​:

On Thu May 19 03​:49​:55 2005\, shay wrote​:

This is a bug report for perl from steve.hay@​uk.radan.com\, generated with the help of perlbug 1.35 running under perl v5.8.6.

I believe that the following program should print "OK" 5 times over\, but it prints "NOT OK" from the first line.

print qq[>10\n] =~ />\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>1\n] =~ />\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ /\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ />\d\d$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ />\d+$ \n/x ? "OK\n" : "NOT OK\n";

I get the same behaviour with 5.6.0 through to 5.8.6 and bleadperl\, all on Windows XP.

I just ran this with a recent blead and got...

[steve@​sulu ~]$ /tmp/bleadperl/bin/perl5.10.0 rt_35877.t OK OK OK OK OK

Can you a few other people double check just to make sure this isn't a heisenbug?

Thanks\,

Steve Peters

I'm not sure if tests for this were added so a patch with the tests of the report is attached.

Are my eyes just glazing over\, or have you got this slightly different to the original bug report?

Your patch has

/>\d+$ \n/ix >10\n /\d+$ \n/ix >1\n /\d+$ \n/ix >10\n />\d\d$ \n/ix >10\n />\d+$ \n/x >10\n

but the original bug report had

/>\d+$ \n/ix >10\n />\d+$ \n/ix >1\n /\d+$ \n/ix >10\n />\d\d$ \n/ix >10\n />\d+$ \n/x >10\n

You seem to have missed a '>' from the second test.

It actually fails either way with maint\, and works either way with blead\, so it probably doesn't matter. I just wondered if there was some significance to your change?

p5pRT commented 16 years ago

From p5p@perl.wizbit.be

Citeren Steve Hay \SteveHay@&#8203;planit\.com​:

Bram via RT wrote​:

On Fri Nov 16 06​:46​:06 2007\, stmpeters wrote​:

On Thu May 19 03​:49​:55 2005\, shay wrote​:

This is a bug report for perl from steve.hay@​uk.radan.com\, generated with the help of perlbug 1.35 running under perl v5.8.6.

I believe that the following program should print "OK" 5 times over\, but it prints "NOT OK" from the first line.

print qq[>10\n] =~ />\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>1\n] =~ />\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ /\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ />\d\d$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ />\d+$ \n/x ? "OK\n" : "NOT OK\n";

I get the same behaviour with 5.6.0 through to 5.8.6 and bleadperl\, all on Windows XP.

I just ran this with a recent blead and got...

[steve@​sulu ~]$ /tmp/bleadperl/bin/perl5.10.0 rt_35877.t OK OK OK OK OK

Can you a few other people double check just to make sure this isn't a heisenbug?

Thanks\,

Steve Peters

I'm not sure if tests for this were added so a patch with the tests of the report is attached.

Are my eyes just glazing over\, or have you got this slightly different to the original bug report?

Your patch has

/>\d+$ \n/ix >10\n /\d+$ \n/ix >1\n /\d+$ \n/ix >10\n />\d\d$ \n/ix >10\n />\d+$ \n/x >10\n

but the original bug report had

/>\d+$ \n/ix >10\n />\d+$ \n/ix >1\n /\d+$ \n/ix >10\n />\d\d$ \n/ix >10\n />\d+$ \n/x >10\n

You seem to have missed a '>' from the second test.

It actually fails either way with maint\, and works either way with blead\, so it probably doesn't matter. I just wondered if there was some significance to your change?

The change was unintended...

New patch attached.

In the meantime I've also done a binary search which says that the problem was fixed with Change 29441.

test_35877.pl #!/usr/bin/perl

print qq[>10\n] =~ />\d+$ \n/ix ? "ok\n" : "not ok\n"; ./perl-p-5.9.4\@​29440/miniperl test_35877.pl not ok

./perl-p-5.9.4\@​29441/miniperl test_35877.pl ok

http​://public.activestate.com/cgi-bin/perlbrowse/p/29441 Change 29441 by rgs@​marais on 2006/12/03 18​:37​:15

  Subject​: Re​: [perl #41010] (?(COND)) in pattern matching not working properly   From​: demerphq \demerphq@&#8203;gmail\.com   Date​: Thu\, 30 Nov 2006 01​:12​:25 +0100   Message-ID​: \9b18b3110611291612i137803f4lab2739e3d9af40f7@&#8203;mail\.gmail\.com

(Your mail got lost in my inbox... else I would have replied sooner)

p5pRT commented 16 years ago

From p5p@perl.wizbit.be

re_35877

p5pRT commented 16 years ago

From @steve-m-hay

Bram wrote​:

Citeren Steve Hay \SteveHay@&#8203;planit\.com​:

Bram via RT wrote​:

On Fri Nov 16 06​:46​:06 2007\, stmpeters wrote​:

On Thu May 19 03​:49​:55 2005\, shay wrote​:

This is a bug report for perl from steve.hay@​uk.radan.com\, generated with the help of perlbug 1.35 running under perl v5.8.6.

I believe that the following program should print "OK" 5 times over\, but it prints "NOT OK" from the first line.

print qq[>10\n] =~ />\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>1\n] =~ />\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ /\d+$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ />\d\d$ \n/ix ? "OK\n" : "NOT OK\n"; print qq[>10\n] =~ />\d+$ \n/x ? "OK\n" : "NOT OK\n";

I get the same behaviour with 5.6.0 through to 5.8.6 and bleadperl\, all on Windows XP.

I just ran this with a recent blead and got...

[steve@​sulu ~]$ /tmp/bleadperl/bin/perl5.10.0 rt_35877.t OK OK OK OK OK

Can you a few other people double check just to make sure this isn't a heisenbug?

Thanks\,

Steve Peters

I'm not sure if tests for this were added so a patch with the tests of the report is attached.

Are my eyes just glazing over\, or have you got this slightly different to the original bug report?

Your patch has

/>\d+$ \n/ix >10\n /\d+$ \n/ix >1\n /\d+$ \n/ix >10\n />\d\d$ \n/ix >10\n />\d+$ \n/x >10\n

but the original bug report had

/>\d+$ \n/ix >10\n />\d+$ \n/ix >1\n /\d+$ \n/ix >10\n />\d\d$ \n/ix >10\n />\d+$ \n/x >10\n

You seem to have missed a '>' from the second test.

It actually fails either way with maint\, and works either way with blead\, so it probably doesn't matter. I just wondered if there was some significance to your change?

The change was unintended...

New patch attached.

Thanks\, applied as #34202.

p5pRT commented 16 years ago

From @steve-m-hay

Apparently fixed by change 29441.

p5pRT commented 16 years ago

@steve-m-hay - Status changed from 'open' to 'resolved'

p5pRT commented 16 years ago

From @rgs

2008/7/24 Bram \p5p@&#8203;perl\.wizbit\.be​:

Citeren Yitzchak Scott-Thoennes \sthoenna@&#8203;efn\.org​:

On Mon\, June 2\, 2008 1​:52 pm\, Bram wrote​:

Quoting David Nicol \davidnicol@&#8203;gmail\.com​:

Warn that non-final $ will interpolate in documentation and suggest \Z instead?

Given how easy it is to miss it I feel more for a 'Possible unintended interpolation of $\ in regex' warning. (if that is even possible of course)

Any comments on the warning?

Sounds great\, if you can make it suppressable with ${\}.

Patch attached.

./perl -wle '"" =~ m/$\s/;' Possible unintended interpolation of $\ in regex at -e line 1.

Thanks\, applied as #34224\, except that I moved the test in t/lib/warnings/toke.