Skip Menu |

This queue is for tickets about the Regexp-Debugger CPAN distribution.

Report information
The Basics
Id: 132683
Status: resolved
Priority: 0/
Queue: Regexp-Debugger

People
Owner: Nobody in particular
Requestors: deven [...] ties.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in:
  • 0.001000
  • 0.001001
  • 0.001002
  • 0.001003
  • 0.001004
  • 0.001005
  • 0.001006
  • 0.001007
  • 0.001008
  • 0.001009
  • 0.001010
  • 0.001011
  • 0.001012
  • 0.001013
  • 0.001014
  • 0.001015
  • 0.001016
  • 0.001017
  • 0.001018
  • 0.001019
  • 0.001020
  • 0.001021
  • 0.001022
  • 0.002000
  • 0.002001
  • 0.002002
  • 0.002003
  • 0.002004
Fixed in: (no value)



Subject: Regexp::Debugger always treats "#" as a comment character regardless of the /x flag.
Regexp::Debugger is awesome! But I did find a bug in it relating to the /x flag... Here is a very simple test case: perl -MRegexp::Debugger -e '/(#)/' This is a perfectly valid regular expression which should match (and capture) a literal "#" character, but if Regexp::Debugger is loaded, it treats the "#" as a comment character, incorrectly commenting out the closing parenthesis and causing an error: Unmatched ( in regex; marked by <-- HERE in m/(?#R_d:0)(?>\A(?{Regexp::Debugger::_reset_debugger_state()})(?!)|\G(?{Regexp::Debugger::_reset_debugger_state_rematch()})(?!))|( <-- HERE ?:(?{Regexp::Debugger::_report_event(0, 0, pos()); $^R})(?=[\d\D]?(?{1}))(?:((?{Regexp::Debugger::_report_event(0, 1, pos()); $^R})(?=[\d\D]?(?{1}))(?:(?>(?{local $Regexp::Debugger::prevpos=pos})#)(?{ if (defined $Regexp::Debugger::prevpos && $Regexp::Debugger::prevpos < pos){ Regexp::Debugger::_report_event(0, 2, $Regexp::Debugger::prevpos); Regexp::Debugger::_report_event(0, 2+1, pos()); }$^R })|(?{ Regexp::Debugger::_report_event(0, 2, pos()); $^R })(?!)))(?{Regexp::Debugger::_report_event(0, 4, pos()); $^R})(?=[\d\D]?(?{1}))|(?{Regexp::Debugger::_report_event(0, 5, pos()); $^R})(?=[\d\D]?(?{1}))(?!))/ at (eval 8) line 8. (This regular expression can also be entered into "rxrx" with similar results.) The "#" should behave as a comment character like this IF the /x flag is on, but in this case it isn't, so it should match literally. (Using "\#" is a workaround for this bug.) This bug is present in every version of Regexp::Debugger from 0.001000 through 0.002004, which is the current version.
Subject: Re: [rt.cpan.org #132683] Regexp::Debugger always treats "#" as a comment character regardless of the /x flag.
Date: Sat, 23 May 2020 03:37:11 +0000
To: bug-Regexp-Debugger [...] rt.cpan.org
From: Damian Conway <damian [...] conway.org>
Hi Deven, It is indeed annoying that R::D can't reliably detect the presence or absence of /x on the regexes it modifies. Unfortunately, as far as I can discover, there is simply no mechanism available in Perl to acquire that information within the overload::constant mechanism that the module uses to inject its debugging behaviours into each regex. The module's documentation is very long, so you may well have missed it, but the "LIMITATIONS" section near the end of the docs specifically highlights this very problem in some detail. And that would have been the end of my response, except that working on your example led me to come up with a sneaky approach that now makes the module much better at correctly inferring whether the /x flag is likely to be in use or not. In fact, sufficiently much better that it now correctly handles your particular example (and most other non-/x cases as well). It's still not perfect, but at least it's no longer hopeless. :-) Alas, I don't foresee that I'm going to be able to fully fix this issue for all possible cases; not until overload::constant is extended to explicitly provide the necessary information. Which I suspect it never will be. :-( Anyway, give the latest release (just uploaded to CPAN) a try and see if it works better for you. Thanks again for bringing this issue to my attention, Damian