-
Notifications
You must be signed in to change notification settings - Fork 540
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
local() in embedded code in regex not working as expected #15056
Comments
From @maukeCreated by @mauke#!/usr/bin/perl my $str = 'ABC'; my @words; $str =~ m{ print "words=[@words]\n"; This program tries to match the string "ABC" as a sequence of segments, each of For debugging purposes it also temporarily records the number of segments used According to the description in perlre, (?{ local $foo = ... }) should set $foo Therefore I expect the correct output of this to be: However, the actual output I get is: That is, despite pos() resetting from 2 to 1, the old values of $count and I get this unexpected output from 5.22.0, 5.23.5, 5.20.1, 5.18.2, 5.16.3, and 5.6.2, however, says: This is almost correct. It properly resets $count and $accum[0]; it just (I wasn't able to test with 5.8 because 'perlbrew install perl-5.8.9' fails at Is this indeed a bug in (at least) 5.14+ or am I missing something? Perl Info
|
From @hvdsOn Fri, 20 Nov 2015 11:59:43 -0800, mauke- wrote:
I don't know if it is a bug, but it appears to be TRIE-specific - if I modify the core capture from '( AB | A | BC )' to '( AB | [AZ] | BC )' to avoid the trie optimization, I get your expected output: ! count=1; accum=[AB]; pos=2 We generally expect that optimizations may alter the course or predictability of backtracking behaviour, but I think it's entirely possible that this is simply a bug. From the -Dr output, I suspect here may be the signal that we've bypassed whatever triggers the unwinding of localization on backtracking: If that's true, we might see similar effects for things like capture buffers that follow a trie. Yves/DaveM, any clue on this? Hugo |
The RT System itself - Status changed from 'new' to 'open' |
From @iabynOn Tue, Feb 07, 2017 at 01:40:32PM -0800, Hugo van der Sanden via RT wrote:
Fixed by the commit below, which is part of a lager branch I've just $s = ("a" x 1000); Here are the commits in the merge: ca81c32 [MERGE] regex (?{...}) and WHILEM scope fixups and here is the commit which fixes this ticket: commit 4ee1652 clear savestack on (?{...}) failure and backtrack -- |
@iabyn - Status changed from 'open' to 'pending release' |
From @khwilliamsonThank you for filing this report. You have helped make Perl better. With the release today of Perl 5.26.0, this and 210 other issues have been Perl 5.26.0 may be downloaded via: If you find that the problem persists, feel free to reopen this ticket. |
@khwilliamson - Status changed from 'pending release' to 'resolved' |
Migrated from rt.perl.org#126697 (status was 'resolved')
Searchable as RT126697$
The text was updated successfully, but these errors were encountered: