develooper Front page | perl.perl5.porters | Postings from October 2015

Re: [perl #126185] /(?-p)/ should be an error

Thread Previous | Thread Next
Karl Williamson
October 7, 2015 19:10
Re: [perl #126185] /(?-p)/ should be an error
Message ID:
On 10/07/2015 05:34 AM, demerphq wrote:
> On 25 September 2015 at 19:03, Victor ADAM <> wrote:
>> # New Ticket Created by  Victor ADAM
>> # Please include the string:  [perl #126185]
>> # in the subject line of all future correspondence about this issue.
>> # <URL: >
>> This is a bug report for perl from,
>> generated with the help of perlbug 1.40 running under perl 5.23.4.
>> -----------------------------------------------------------------
>> [Please describe your issue here]
>> How to reproduce
>> ----------------
>>> perl5.23.4 -e '/(?-p)/p; print defined for ${^MATCH}, ${^PREMATCH}, ${^POSTMATCH}'
>> Expected behavior
>> -----------------
>> Perl should die with the following diagnostic:
>>> Regexp modifier "p" may not appear after the "-" in regex; marked by <-- HERE in m/(?-p <-- HERE )/ at -e line 1.
> I dont know that I agree that Perl should die. We warn instead:
> $ ./perl -we'qr/(?-p)foo/'
> Useless use of (?-p) in regex; marked by <-- HERE in m/(?-p <-- HERE
> )foo/ at -e line 1.
> Given the mild consequences of this type of mistake I think warnings
> are sufficient.
> Unless someone strongly disagrees I would like  to close this ticket
> as "wont fix".
> Thanks for the report though!

I agree with Yves.  But I think the ticket should be rejected rather 
than wont fix, as I think the latter indicates that we agree that this 
is a problem but the downside of changing it outweighs the upside (for 
example too hard to fix or it would break too much existing code).  And 
here, I think that the consequences are mild, so it was the right design 
decision to be a warning.  There are places where I think we've made the 
wrong design decision and carried on in the face of garbage input and 
done some action that is almost certainly not what was intended, but 
this isn't one of those places IMO.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About