diff options
author | Karl Williamson <khw@cpan.org> | 2014-08-07 10:45:21 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2014-08-08 12:49:17 -0600 |
commit | 842a9d211f60b9643f4a6707f378be70fa2fbb9e (patch) | |
tree | 59cc569b8e61df9c83d9038e66f044d08126b010 /t | |
parent | bc6f2746c1999c5e2645423e6c4ab456c68ba8e1 (diff) | |
download | perl-842a9d211f60b9643f4a6707f378be70fa2fbb9e.tar.gz |
PATCH: [perl #122460] Regression with (?{})(?=...) and pos
The commit that really broke this was
a0dd42312a1f26356d2fdf49656e45b77c2cefb5. The blamed commit fixed some
typos that kept the earlier bad commit from having an effect.
Zero-length assertions, such as (?=...) obviously can match an empty
string. The bad commit wrongly removed a setting of a flag to that
effect. I didn't realize the implications at the time, thinking that
the newly-corrected AND logical operations would correctly set things
up, and that the previous code had been a workaround for the buggy AND.
The problem is that there is an overriding context such that whatever
the AND result, since this is in a 0-length assertion, the result will
match the empty string. Thus it now differs from the pre-bad-commit
code which set to match the empty string only sometimes. I'm pretty
sure it should be 'always'. If I'm wrong, it doesn't mean a bug, but
only that an optimisation that could take place won't.
Diffstat (limited to 't')
-rw-r--r-- | t/re/pat_advanced.t | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/t/re/pat_advanced.t b/t/re/pat_advanced.t index 82f0917655..986eb87de4 100644 --- a/t/re/pat_advanced.t +++ b/t/re/pat_advanced.t @@ -2346,6 +2346,12 @@ EOP is($word, 'раб', "Handles UTF8 trie correctly"); } + { # [perl #122460] + my $a = "rdvark"; + $a =~ /(?{})(?=[A-Za-z0-9_])a*?/g; + is (pos $a, 0, "optimizer correctly thinks (?=...) is 0-length"); + } + # # Keep the following tests last -- they may crash perl # |